Generate correct code for locals.

This commit is contained in:
Bob Nystrom
2013-11-09 11:38:01 -08:00
parent a2f0e41bcb
commit 0cc5524249
9 changed files with 64 additions and 16 deletions
+6
View File
@@ -0,0 +1,6 @@
class Foo {
bar {
var a = "value"
var a = "other" // expect error
}
}
+6
View File
@@ -0,0 +1,6 @@
class Foo {
bar(arg,
arg) { // expect error
"body"
}
}
+5
View File
@@ -0,0 +1,5 @@
class Foo {
bar(a) {
var a = "oops" // expect error
}
}
+14
View File
@@ -0,0 +1,14 @@
class Foo {
bar {
var a = "a"
io.write(a) // expect: a
var b = a + " b"
io.write(b) // expect: a b
var c = a + " c"
io.write(c) // expect: a c
var d = b + " d"
io.write(d) // expect: a b d
}
}
Foo.new.bar