Repository navigation
Description
Compiler: 1.9.0.0-nightly-1-g2d53fc14e (installed by wurst4vscode 0.12.29, grill 1.4.0)
Stdlib: wurstStdlib2 master 8ac65c6
Script mode: JASS, wc3Patch: v3.0
Repro
Use a fresh grill generate <name> --script-mode jass project with this as its only package:
package Repro
import LinkedList
interface StringFn
function get(int i) returns string
let names = asList("a", "b")
init
StringFn f = i -> names.get(i)
print(f.get(0))
grill typecheck fails:
Error output.j:754: Generated Jass failed validation: Cannot convert string to integer in parameter index in call to stringFromIndex Please report this compiler error.
Generated Jass:
function get_Repro takes integer this, integer i returns string
return stringFromIndex(stringFromIndex(dispatch_LinkedList_LinkedList_get(Repro_names, i)))
endfunctionThe closure body converts the old-generic LinkedList<string> value back to a string, and so does the closure's return. That's two conversions.
Compile-time variant
The same closure in an @compiletime function crashes the interpreter:
@compiletime function reproCompiletime()
StringFn f = i -> names.get(i)
print(f.get(0))
You encountered a bug in the interpreter: java.lang.Error: The native <LoadStr> expects different parameter 2!
Hashtable.wurst:101 inside call hashtable_loadString(ht690, 2, "a")
Table.wurst:59 inside call Table_loadString(Table_2, "a")
TypeCasting.wurst:42 inside call stringFromIndex("a")
Repro.wurst:10 inside call get_Repro(StringFn_Repro_1, 0)
In a real map this hits object editing, for example AbilityDefinitionSpellBook.presetSpellList(lvl -> abilityList.get(lvl)) with abilityList: HashMap<int, string>.
Control
The same read in a plain function compiles correctly, with a single stringFromIndex:
function getName(int i) returns string
return names.get(i)
function getName takes integer i returns string
return stringFromIndex(dispatch_LinkedList_LinkedList_get(Repro_names, i))
endfunctionSeen in Island Troll Tribes with HashMap<int, string> and LinkedList<string> read inside StringLevelClosures. The workaround was to read outside the closure.
Related: debug builds hit Jass limits that release builds don't
These are from the same map, Island Troll Tribes, with JASS mode and grill run, so -stacktraces was on. Neither is a compiler bug as such, but both are easy for a large map to hit, and the first one fails silently until runtime. Worth considering compiler warnings for them.
-
Hard crash from too many parameters. Vararg calls compile to one Jass parameter per element, and stack traces add a hidden
string w__wurst_stackPosparameter.new HashSet<string>()..add(<29 strings>)generatedHashSet_add_29with 31 parameters, and WC3 (3.0.0.24268) crashed with ACCESS_VIOLATION during package init. A 30-elementasList(...)producedasList_30with 31 parameters too. Splitting the calls fixed it. A warning or error when a generated function crosses the limit would have saved a lot of bisecting. -
Package init over the op limit. A package with 1,110
public let X = compiletime(GEN.next())..registerObjectID("X")globals died at Add doc comments #1,096 with "Could not initialize package". Moving each registration intoexecute()fixed it.
Activity
Frotty commentedon Oct 13, 2026
The old-generic closure bug is reproduced and fixed in #1446. Expression translation already decoded the container's result, and closure-return translation decoded it again. The fix emits one
stringFromIndexcall. Runtime and compile-time repros fail before the fix and pass afterward; regression coverage includes Jass, Lua, and a new-generic control.For the debug-build observations:
Use the default Lua target unless you need Jass compatibility. Lua avoids this Jass-specific argument limit, so new maps should not opt into Jass mode without a compatibility requirement.
New generics are also recommended. Prefer new-generic containers where they fit, e.g.
asArrayList(...)/ArrayList<T:>for indexed lists andIntMap<V:>for integer-keyed maps. They preserve native value representations rather than routing strings through integer indices, avoiding this particular conversion bug and its overhead. The existingLinkedList,HashMap, andHashSetdeclarations still use old generics, so changing surrounding code to new generics does not migrate those containers. New generics do not remove Jass's parameter or operation limits if you continue targeting Jass; the old-generic compiler bug is fixed independently.Validation: 106 focused compiler tests passed, plus the real-client parameter probes above.