lang: Fix import scoping issue with classes
When include-ing a class, we propagated the scope of the include into the class instead of using the correct scope that existed when the class was defined and instead propagating only the include arguments in. This patch fixes the issue and adds a ton of tests as well. It also propagates the scope into the include args, in case that is needed, and adds a test for that as well. Thanks to Nicolas Charles for the initial bug report.
This commit is contained in:
12
lang/interpret_test/TestAstFunc1/recursive_class1/main.mcl
Normal file
12
lang/interpret_test/TestAstFunc1/recursive_class1/main.mcl
Normal file
@@ -0,0 +1,12 @@
|
||||
import "fmt"
|
||||
$max = 3
|
||||
include c1(0) # start at zero
|
||||
class c1($count) {
|
||||
if $count == $max {
|
||||
test "done" {
|
||||
stringptr => fmt.printf("count is %d", $count),
|
||||
}
|
||||
} else {
|
||||
include c1($count + 1) # recursion not supported atm
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user