HaxeFoundation / HaxeFoundation/haxe

Not_found when nesting @:generic type and field

Open
#4,294 2 comments 0 reactions 1 assignee Claimed by @Simn View on GitHub
feature-generic
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```
class Main {
static function main() {
var k = new X();
}
}

@:generic
class X {
public function new() {
var k:String = test();
}

@:generic function test():C2 {
return null;
}
}
```

```
Fatal error: exception Not_found
Raised at file "type.ml", line 743, characters 36-45
Called from file "type.ml", line 765, characters 16-59
Called from file "codegen.ml", line 298, characters 40-64
```

Some debug output:

```
Add copied field test to X_Main.cl_ordered_fields
Make generic field: test_String on X
Check field test_String on X_Main
```

So the problem is that at the time of copying the fields we do not yet have the generic specialization test_String because that is only created once we type the call to it in X.new. Intuitively I would say that we should type the entire generic base class before we start making copies of its fields, but I'm pretty sure this is going to be headache material.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.