Got scope-based variable shadowing working

This commit is contained in:
2022-08-14 21:32:13 +01:00
parent 4aa6f75ea7
commit 9e899f5974
5 changed files with 50 additions and 9 deletions

View File

@@ -37,6 +37,22 @@ print 1.0 / 2.0;
}
print "Back to the outer scope.";
//test scope will delegate to higher scope
var a = 1;
{
a = 2;
print a;
}
print a;
//test scope will shadow higher scope on redefine
var b = 3;
{
var b = 4;
print b;
}
print b;
//test compounds, repeatedly
print [1, 2, 3];
print [4, 5];
@@ -69,4 +85,6 @@ assert x, "This won't be seen";
assert true, "This won't be seen";
assert false, "This is a failed assert, and will end execution";
print "This will not be printed because of the above assert";
print "This will not be printed because of the above assert";
//TODO: use a proper assert-based version of this file

View File

@@ -1,2 +1,2 @@
var name : [string const, int] = ["foo" : 42];
var something = 0;