We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 082a837 commit 7b0bab7Copy full SHA for 7b0bab7
test_programs/r4/3.lox
@@ -1,3 +1,18 @@
1
---
2
-expected_error_type: none
+expected_error_type: compile
3
4
+fun returnArg(arg) {
5
+ return arg;
6
+}
7
+
8
+var b = "global";
9
10
+{
11
+ var a = "first";
12
+ var b = returnArg(b); // Using global 'b' in its initializer, but through a function call
13
+ print b;
14
15
16
+// Reassigning with self-reference is fine for globals
17
+var b = b + " updated";
18
+print b;
test_programs/r4/4.lox
@@ -1,3 +1,15 @@
+fun outer() {
+ var a = "outer";
+ fun inner() {
+ var a = a; // Error at 'a': Can't read local variable in its own initializer.
+ print a;
+ }
+ inner();
+outer();
0 commit comments