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

EFieldKind messes with macro pattern matching. #11198

Open
back2dos opened this issue May 3, 2023 · 2 comments
Open

EFieldKind messes with macro pattern matching. #11198

back2dos opened this issue May 3, 2023 · 2 comments

Comments

@back2dos
Copy link
Member

back2dos commented May 3, 2023

I suspect this is the commit: f90995b

import haxe.macro.Expr;
using haxe.macro.Tools;

class Test {
    static function main() {
        var exprs = [
            macro a.b,
            {
                pos: (macro null).pos,
                expr: EField(macro a, 'b')
            },
            {
                pos: (macro null).pos,
                expr: EField(macro a, 'b', Normal),
            }
        ];
        
        for (e in exprs) {
            trace(e.toString() + ' matches a.b:' + switch e {
                case macro a.b: true;
                default: false;
            });
        }
    }
}

The above traces true, false, true - the false being the problem, because case macro a.b appears to explicitly match for Normal. That's a bit of a problem. I think the simplest solution would be to make EFieldKind an enum abstract, with var Normal = null;.

back2dos added a commit to haxetink/tink_hxx that referenced this issue May 3, 2023
@Simn
Copy link
Member

Simn commented May 3, 2023

Yes that's a bit silly indeed... HaxeFoundation/haxe-evolution#27 would help here, I suppose.

@back2dos
Copy link
Member Author

back2dos commented May 3, 2023

Arguably, that'd be even better ;)

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

No branches or pull requests

2 participants