Start getting block scope working.
This commit is contained in:
@@ -36,3 +36,11 @@ if
|
||||
// Newline after "else".
|
||||
if (false) io.write("bad") else
|
||||
io.write("good") // expect: good
|
||||
|
||||
// Definition in then arm.
|
||||
if (true) var a = io.write("ok") // expect: ok
|
||||
if (true) class Foo {} // no error
|
||||
|
||||
// Definition in else arm.
|
||||
if (false) null else var a = io.write("ok") // expect: ok
|
||||
if (true) null else class Foo {} // no error
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Create a local scope for the 'then' expression.
|
||||
var a = "out"
|
||||
if (true) var a = "in"
|
||||
io.write(a) // expect: out
|
||||
|
||||
// Create a local scope for the 'else' expression.
|
||||
var b = "out"
|
||||
if (false) "dummy" else var b = "in"
|
||||
io.write(b) // expect: out
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
var a = "first"
|
||||
io.write(a) // expect: first
|
||||
}
|
||||
|
||||
{
|
||||
var a = "second"
|
||||
io.write(a) // expect: second
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Body has its own scope.
|
||||
var a = "outer"
|
||||
var i = 0
|
||||
while ((i = i + 1) <= 1) var a = "inner"
|
||||
io.write(a) // expect: outer
|
||||
|
||||
// TODO(bob): What about condition?
|
||||
@@ -29,3 +29,7 @@ var f = while (e < 3) {
|
||||
e = e + 1
|
||||
}
|
||||
io.write(f) // expect: null
|
||||
|
||||
// Definition body.
|
||||
while (false) var a = "ok" // no error
|
||||
while (false) class Foo {} // no error
|
||||
|
||||
Reference in New Issue
Block a user