Slice allows you to use keywords as an identifier provided you escape them:
However, the way that we handle them under the hood is incorrect and buggy.
This is because right now the \ backslash only exists at lexing time: when the lexer sees an identifier, normally it first performs a lookup against a list of keywords, and only if there is no match do we skip. Either way, the lexer eats the \, and from then on int32 is indistinguishable from the keyword name.
Proposed fix:
We should keep the backslash around as part of the identifier, so that \int32 and int32 can be distinguished not just by the lexer, but by the redefinition checker, the type-patcher, etc.
For correctness' sake though, we should still eat the \ in cases where it's non-useful. For example, it's valid to escape something that isn't a keyword (with the rationale being consistency and because keywords may be added/removed in the future). But, it's important to remove \ in these cases because:
"\Foo" and "Foo" => there should be no difference between these identifiers
"\bool" and "bool" => there should be a difference between these identifiers
Slice allows you to use keywords as an identifier provided you escape them:
However, the way that we handle them under the hood is incorrect and buggy.
This is because right now the
\backslash only exists at lexing time: when the lexer sees an identifier, normally it first performs a lookup against a list of keywords, and only if there is no match do we skip. Either way, the lexer eats the\, and from then onint32is indistinguishable from the keyword name.Proposed fix:
We should keep the backslash around as part of the identifier, so that
\int32andint32can be distinguished not just by the lexer, but by the redefinition checker, the type-patcher, etc.For correctness' sake though, we should still eat the
\in cases where it's non-useful. For example, it's valid to escape something that isn't a keyword (with the rationale being consistency and because keywords may be added/removed in the future). But, it's important to remove\in these cases because: