Skip to content

defer, %defer, and ?defer #110

@andrewrk

Description

@andrewrk
  • defer expr, evaluates expr when control flow leaves scope
  • %defer expr, evaluates expr when control flow leaves scope by returning an error from the function
  • ?defer expr, evaluates expr when control flow leaves scope by returning null from the function
  • defer valid at statement level only in parser
  • error when there is a defer with 0 block exit paths
  • make the returns respect defer
  • error when there is a %return in a function with void return type
  • optimization where the node remembers if it was error wrapped from a payload, if that is returned, then we know it is not an error. when %return returns it is for sure an error. otherwise we have to do a runtime check to find out if it's an error and then do the defer expression
  • better defer implementation - instead of duplicating the code at every exit path, make a basic block that exit paths point to.
  • error for control flow inside an expression exiting the defer expression scope? for example you probably shouldn't be able to return in a defer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions