Open camc opened 3 years ago
what should this do, then?
let ab := 1;
if ab == 1 {
let a := 2;
a := 3;
println(a);
}
println(ab);
maybe referring to an ident directly (not a prefix) should be allowed?
IMHO your example is just a consequence of shadowing. If we want to change this, there are some thorny edge-cases. For example, what if we shadow the variable like this?
let ab := 1;
if ab == 1 {
let ab := 2;
a := 3;
println(ab);
}
println(ab);
Shadowing aside, it is possible to have an identifier that is a prefix of another identifier:
let ab := 1;
let a := 3;
print(a); ???;
I think an exact match should win in this case.
This also means we might need to trim identifiers. Right now let a := 1;
produces an identifier a
, which does not exact match to a
from print(a)
.
I didn't know we allowed shadowing :laughing:
This also means we might need to trim identifiers. Right now let a := 1; produces an identifier a , which does not exact match to a from print(a).
I think this is no longer the case, I started trimming them in the lexer
The following should be an error: