HaxeFoundation / HaxeFoundation/haxe
`haxe.macro.TypeTools.toBaseType` better error reporting
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
If `toBaseType` (or well, `toModuleType`, so actually `type_to_module_type`) gets called with unsupported type, the error is just:
```
[ERROR] (unknown position)
| Stdlib.Exit
```
It would be nice if the error had a message and proper position. Sample code:
```haxe
// Main.hx
class Test {
static function main() {
var a:Foo; // Good.
var b:Foo<{anonType:Bool}>; // Not good.
}
}
@:genericBuild(Macro.build()) class Foo {}
// Macro.hx
class Macro {
static public function build() {
switch (haxe.macro.Context.getLocalType()) {
case TInst(_, [t1]):
trace(haxe.macro.TypeTools.toBaseType(t1));
case t:
}
return null;
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.