Skip to content

Possible to use @:await inside expression macros? #13

@kevinresol

Description

@kevinresol
// Main.hx
@:await
class Main {
    @:await static function main() {
      var s:String = Macro.expr();
    }

    @:async static function string() return 'hi';
}

// Macro.hx
class Macro {
    public static macro function expr() {
        return macro @:await string();
    }
}

The above code won't work because the await macro runs first. After that the typer kicks in and transform the macro call to actual expression. As a result, the generated expression (@:await string()) won't get handled by the await macro.

So, are there any workarounds for that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions