Commit 2ec9571
committed
Do not read a type argument by position when the arities differ
Resolving a type class dispatch looked up the type variable's position and then
indexed the type arguments without checking the two lists correspond. A method
which declares its own type parameters alongside its class's is called with only
its own, so position no longer means anything: the class's variable read the
method's argument, and a later variable would have run off the end.
That is the same positional confusion already fixed for the interpreter, still
present in the specializer. Both lookups now bail when the arities disagree, so a
dispatch is left for a pass that has matching arguments rather than resolved
against whichever type happened to sit at that index.
The shape which exposed this, a bounded generic class method with an independent
type parameter, is unsupported on Lua by design and still reports an error there;
it never produced a wrong result, which was verified by making a wrong dispatch
resolvable and confirming it still failed.1 parent 50b8413 commit 2ec9571
1 file changed
Lines changed: 7 additions & 1 deletion
File tree
- de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtranslation
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1153 | 1153 | | |
1154 | 1154 | | |
1155 | 1155 | | |
1156 | | - | |
| 1156 | + | |
1157 | 1157 | | |
1158 | 1158 | | |
1159 | 1159 | | |
| |||
1187 | 1187 | | |
1188 | 1188 | | |
1189 | 1189 | | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
1190 | 1196 | | |
1191 | 1197 | | |
1192 | 1198 | | |
| |||
0 commit comments