HaxeFoundation / HaxeFoundation/haxe
unhelpful error position for @:generic+Constructible+new
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
*(extracted from a [forum question](https://community.haxe.org/t/generic-class-with-t-dynamic-referenced-for-type-possibly-instantiated/2480))*
```haxe
import haxe.Constraints.Constructible;
@:generic
class GenericBase Void>> {
public function new() {
new T();
}
}
function main() {
new GenericBase();
}
```
This will error `src/Main.hx:5: lines 5-7 : Dynamic has no field new`, but the position is pointing to `GenricBase.new` method which is unhelpful. We should probably add one of these "called from here" line for it, so the user knows what caused invalid @:generic instantiation. Or maybe we could error even before @:generic is instantiated, by not allowing `Dynamic` to pass `Constructible` constraint check.
Contributor guide
Research direction
Reproduce the example in src/Main.hx and inspect the compiler diagnostic for the @:generic Constructible instantiation. Trace where the error is reported versus where new GenericBase() triggers it. Done means the diagnostic identifies the instantiation or provides a useful “called from here” location, with the example covered by a regression check.
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