Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform function expression in expression macro instead of build macro #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jonasmalacofilho
Copy link

At that point, all fields have been typed and that information can be used, as with Context.typeof in ETry expression handling.

This fixes the ETry handling, that was partially broken. It used Context.typeof before the field was typed, and thus didn't recognize valid identifiers such as local variables or other fields. The following example illustrates what failed with Unknown identifier : bar before and now works:

@:build(com.dongxiguo.continuation.Continuation.cpsByMeta("async"))
class Test {
    @async static function foo(bar:String):Int
    {
        var x = try {
            // sync stuff only, obviously
            bar;
        } catch (e:Dynamic) {
            return 1;
        }
        // some async stuff
        return 0;
    }
    static function main()
    {
        foo("hi", function (code) trace(code));
    }
}

At that point, all fields have been typed and that information can be
used, as with `Context.typeof` in `ETry` expression handling.

This fixes the `ETry` handling, that was partially broken.  It used
`Context.typeof` before the field was typed and, therefore, didn't
recognize valid identifiers such as local variables or other fields.
The following example illustrates what failed with
    `Unknown identifier : bar`
before and now works:

    @:build(com.dongxiguo.continuation.Continuation.cpsByMeta("async"))
    class Test {
        @async static function foo(bar:String):Int
        {
            var x = try {
                // sync stuff only, obviously
                bar;
            } catch (e:Dynamic) {
                return 1;
            }
            // some async stuff
            return 0;
        }
        static function main()
        {
            foo("hi", function (code) trace(code));
        }
    }
@jonasmalacofilho
Copy link
Author

Actually, this breaks compiler completion, so don't merge yet. I'm working on a fix... (fixed in c6ee003)

This fixes completion issues accidentally introduced with delaying
expression transformation to when all fields have been typed.

The position argument passed to `--display` must match the generated
expression, and is usually inferred by tools from the source file.
However, macro reification by default annotates the expression as
positioned on the reification site, not on the original expression
position, and thus makes them invisible or incorrectly placed for the
completion engine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant