syntax: Make 'true' and 'false' bad words
When these are idents they are always shadowed by the boolean constants.
This commit is contained in:
parent
98ac8d4625
commit
08d0707556
3 changed files with 7 additions and 5 deletions
|
@ -213,7 +213,6 @@ fn keyword_table() -> hashmap<str, ()> {
|
|||
"as",
|
||||
"bind",
|
||||
"else",
|
||||
"false",
|
||||
"implements",
|
||||
"move",
|
||||
"of",
|
||||
|
@ -222,7 +221,6 @@ fn keyword_table() -> hashmap<str, ()> {
|
|||
"send",
|
||||
"static",
|
||||
"to",
|
||||
"true",
|
||||
"use",
|
||||
"with"
|
||||
];
|
||||
|
@ -241,9 +239,9 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
|
|||
let words = str_hash();
|
||||
let keys = ["alt", "assert", "be", "break", "check", "claim",
|
||||
"class", "const", "cont", "copy", "crust", "do", "else",
|
||||
"enum", "export", "fail", "fn", "for", "if", "iface",
|
||||
"impl", "import", "let", "log", "loop", "mod",
|
||||
"mut", "native", "new", "pure", "resource",
|
||||
"enum", "export", "fail", "false", "fn", "for", "if",
|
||||
"iface", "impl", "import", "let", "log", "loop", "mod",
|
||||
"mut", "native", "new", "pure", "resource", "true",
|
||||
"ret", "trait", "type", "unchecked", "unsafe", "while"];
|
||||
for keys.each {|word|
|
||||
words.insert(word, ());
|
||||
|
|
2
src/test/compile-fail/bad-value-ident-false.rs
Normal file
2
src/test/compile-fail/bad-value-ident-false.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
fn false() { } //! ERROR found `false` in expression position
|
||||
fn main() { }
|
2
src/test/compile-fail/bad-value-ident-true.rs
Normal file
2
src/test/compile-fail/bad-value-ident-true.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
fn true() { } //! ERROR found `true` in expression position
|
||||
fn main() { }
|
Loading…
Add table
Add a link
Reference in a new issue