feat: add superclass call support inside closures in wren compiler
Add a new test case `test/super/closure.wren` verifying that `super.toString` correctly resolves to the base class method when called from within a closure defined in a derived class. Refactor `resolveLocal` and `resolveUpvalue` to accept explicit name and length parameters instead of relying on the previously consumed token, enabling proper name resolution in nested closure scopes during superclass method dispatch.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
class Base {
|
||||
toString { return "Base" }
|
||||
}
|
||||
|
||||
class Derived is Base {
|
||||
getClosure {
|
||||
return fn {
|
||||
return super.toString
|
||||
}
|
||||
}
|
||||
|
||||
toString { return "Derived" }
|
||||
}
|
||||
|
||||
var closure = (new Derived).getClosure
|
||||
IO.write(closure.call) // expect: Base
|
||||
Reference in New Issue
Block a user