HaxeFoundation / HaxeFoundation/haxe

Result of Context.getExpectedType() depends on prev Context.typeof() calls.

Open
#12,212 0 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

If macro function receives non primitive args, `getExpectedType()` returns null after `Context.typeof()` call.
Reproduces on all the nightlies but works fine on 4.3.6.
```haxe
class Macro {
public static macro function create2(extra:Array) {
trace( Context.getExpectedType()); //TType(Map,[TInst(String,[]),TAbstract(Int,[])])
var valCt0 = Context.typeof(extra[0]);
trace( Context.getExpectedType()); // null
return macro null;
}
}
class Test {
static function main() {
var avec2:Map = Macro.create2(new haxe.ds.Vector(1)); // arguments of primitive types does'n break results
}
}
```
https://try.haxe.org/#70A7a3b4

Contributor guide

Open the contributing guide

Research direction

Start with the Context.getExpectedType() and Context.typeof() macro API entry points, then run the linked Try Haxe reproduction against the affected nightlies and 4.3.6. Done means getExpectedType() continues to return the expected Map type after typeof() is called on a non-primitive argument.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.