Repository navigation
Comparing changes
Open a pull request
base repository: wurstscript/WurstScript
base: master
head repository: wurstscript/WurstScript
compare: lua-closure-instanceof-identity
- 6 commits
- 9 files changed
- 1 contributor
Commits on Oct 21, 2026
-
Lua: tell the instantiations apart in an instanceof written in a closure
An instanceof Box<T> in a closure written in a method of a generic class accepted every Box on Lua. #1507 kept closures erased for an instanceof, because specialising one left its captured receiver typed by the erased class; #1512 fixed that receiver, so the exclusion is lifted: an instanceof of the type parameter now counts towards a closure's identity like any other member which needs its type argument. A closure which constructs the Box<T> another closure checks still stayed erased. Box<int> is observed only once the checking closure is specialised, in the second round, but classNeedsIdentity keeps its first answer, given in the first. Whether an instanceof observes a class is now collected once, before the specialisation, from every parameterised instanceof, including one still written with a type variable. The IM interpreter compared only the class in an instanceof, so it took a Box<string> for a Box<int> in compile-time code and @test functions. It now compares the type arguments of the instantiation too. The audit tests for instanceof identity run the interpreter on the generic program again. Removes the nine INSTANCEOF_CLOSURE cases from the matrix's known failures and the lua-instanceof-erased backlog entry. Records a crash found on the way: a closure inside another closure which uses its owner's T fails in EliminateGenerics on Jass and Lua.
Configuration menu - View commit details
-
Copy full SHA for 3fd442a - Browse repository at this point
Copy the full SHA 3fd442aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7588a11 - Browse repository at this point
Copy the full SHA 7588a11View commit details -
Compare instantiations in the interpreter's instanceof as the special…
…isation does Type-class bindings are dispatch metadata, which GenericTypes ignores at every nesting level when it tells specialisations apart; the interpreter now compares an object's instantiation with the checked one the same way, instead of through equalsType, which compares nested bindings. Adds a check of a type argument with a bound inside it, built directly and through generic functions.
Configuration menu - View commit details
-
Copy full SHA for 3e5f579 - Browse repository at this point
Copy the full SHA 3e5f579View commit details -
Check every path to a generic supertype in the interpreter's instanceof
A class which reaches one generic interface through two others, as G<int> and as G<string>, is an instance of both, as on Jass and Lua. The interpreter compared the checked instantiation with the first path to the interface only, so one of the two checks was false. It now collects the instantiations of every path.
Configuration menu - View commit details
-
Copy full SHA for 4eb1129 - Browse repository at this point
Copy the full SHA 4eb1129View commit details -
Merge remote-tracking branch 'origin/master' into lua-closure-instanc…
…eof-identity # Conflicts: # BACKLOG.md
Configuration menu - View commit details
-
Copy full SHA for f0f6c07 - Browse repository at this point
Copy the full SHA f0f6c07View commit details -
Give a closure written inside another closure its owner's type parame…
…ters (#1516) * Give a closure written inside another closure its owner's type parameters A closure written in another closure, in a generic class or function, made EliminateGenerics throw "Rewrite generics with wrong sizes" on Jass and Lua whenever either closure used the owner's T, even for a plain field read. The inner closure is translated while the enclosing closure's class is being created, before that class has its captured type variables: the inner closure captured the enclosing this as a class type without type arguments, and the enclosing closure allocated the inner one without them. ClosureTranslator now leaves the type variables of a closure written in another one to the outermost closure, which captures the same variables, all that any closure of the nest uses and in the same order, for each class of the nest, and makes each class name the others with its own variables. A closure with no closure inside it captures what it captured before. With that, EliminateGenerics no longer leaves such closures out of classNeedsIdentity (isInsideAnotherClosure), so on Lua an instanceof Box<T> in an inner closure tells the instantiations apart too. * Turn the test of a rejected nested closure into a success case TypeClassTests pinned that a closure written inside another one in a bounded generic function was rejected on Lua ("could not be resolved for the Lua target"), and asked to become a success case once that works. It works now: the program dispatches on the bound on Jass, the interpreter and Lua.
Configuration menu - View commit details
-
Copy full SHA for 359a92c - Browse repository at this point
Copy the full SHA 359a92cView commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff master...lua-closure-instanceof-identity