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:
Bob Nystrom
2013-12-23 04:46:12 +00:00
parent 75d9a39040
commit 634e9fbb11
2 changed files with 60 additions and 42 deletions
+16
View File
@@ -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