Promote most restricted keywords to strict keywords

This commit is contained in:
Brian Anderson 2012-09-09 23:03:46 -07:00
parent 233e595b61
commit ef9aa80438
8 changed files with 31 additions and 24 deletions

View file

@ -411,22 +411,13 @@ fn contextual_keyword_table() -> hashmap<~str, ()> {
fn restricted_keyword_table() -> hashmap<~str, ()> { fn restricted_keyword_table() -> hashmap<~str, ()> {
let words = str_hash(); let words = str_hash();
let keys = ~[ let keys = ~[
~"as",
~"assert",
~"break",
~"const", ~"copy", ~"const", ~"copy",
~"do", ~"drop", ~"fail", ~"fn",
~"else", ~"enum", ~"export", ~"extern", ~"impl",
~"fail", ~"false", ~"fn", ~"for", ~"priv", ~"pub",
~"if", ~"impl", ~"import", ~"return",
~"let", ~"log", ~"loop",
~"match", ~"mod", ~"move", ~"mut",
~"priv", ~"pub", ~"pure",
~"ref", ~"return",
~"struct", ~"struct",
~"true", ~"trait", ~"type", ~"unsafe"
~"unchecked", ~"unsafe", ~"use",
~"while"
]; ];
for keys.each |word| { for keys.each |word| {
words.insert(word, ()); words.insert(word, ());
@ -438,6 +429,19 @@ fn restricted_keyword_table() -> hashmap<~str, ()> {
fn strict_keyword_table() -> hashmap<~str, ()> { fn strict_keyword_table() -> hashmap<~str, ()> {
let words = str_hash(); let words = str_hash();
let keys = ~[ let keys = ~[
~"as", ~"assert",
~"break",
~"do", ~"drop",
~"else", ~"enum", ~"export", ~"extern",
~"false", ~"for",
~"if", ~"import",
~"let", ~"log", ~"loop",
~"match", ~"mod", ~"move", ~"mut",
~"pure",
~"ref",
~"true", ~"trait", ~"type",
~"unchecked", ~"use",
~"while"
]; ];
for keys.each |word| { for keys.each |word| {
words.insert(word, ()); words.insert(word, ());

View file

@ -1,2 +1,2 @@
fn false() { } //~ ERROR found `false` in restricted position fn false() { } //~ ERROR found `false` in ident position
fn main() { } fn main() { }

View file

@ -1,2 +1,2 @@
fn true() { } //~ ERROR found `true` in restricted position fn true() { } //~ ERROR found `true` in ident position
fn main() { } fn main() { }

View file

@ -0,0 +1,3 @@
mod break {
//~^ ERROR found `break` in ident position
}

View file

@ -1,7 +1,7 @@
// error-pattern:found `let` in restricted position // error-pattern:found `fail` in restricted position
fn main() { fn main() {
match true { match true {
{let} { } {fail} { }
} }
} }

View file

@ -1,5 +1,5 @@
// error-pattern:found `let` in restricted position // error-pattern:found `fail` in restricted position
fn main() { fn main() {
enum let = int; enum fail = int;
} }

View file

@ -7,8 +7,8 @@ mod cat {
#[path = "cat.rs"] #[path = "cat.rs"]
mod inst; mod inst;
#[path = "trait.rs"] #[path = "trait_.rs"]
mod trait; mod trait_;
} }
@ -20,7 +20,7 @@ mod dog {
#[path = "dog.rs"] #[path = "dog.rs"]
mod inst; mod inst;
#[path = "trait.rs"] #[path = "trait_.rs"]
mod trait; mod trait_;
} }