HaxeFoundation / HaxeFoundation/haxe

EFieldKind messes with macro pattern matching.

Open
#11,198 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

I suspect this is the commit: https://github.com/HaxeFoundation/haxe/commit/f90995b7b24b6c96ef5233ce4fe20a358dddb8fe

```haxe
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;`.

Contributor guide

Open the contributing guide

Research direction

Reproduce the provided Haxe macro example and compare the three EField constructions, then inspect commit f90995b7b24b6c96ef5233ce4fe20a358dddb8fe. Trace how EFieldKind affects macro pattern matching. Done means the Normal form matches case macro a.b consistently with the other equivalent expression.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.