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

View File

@ -1,2 +1,2 @@
fn true() { } //~ ERROR found `true` in restricted position
fn true() { } //~ ERROR found `true` in ident position
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() {
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() {
enum let = int;
enum fail = int;
}

View File

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