Disallow block as a variable name in preparation for it becoming a keyword.
This commit is contained in:
@@ -103,11 +103,11 @@ fn visit_expr(&@ctx cx, &@ast::expr ex, &scope sc, &vt[scope] v) {
|
|||||||
case (_) { }
|
case (_) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::expr_for_each(?decl, ?call, ?block) {
|
ast::expr_for_each(?decl, ?call, ?blk) {
|
||||||
check_for_each(*cx, decl, call, block, sc, v);
|
check_for_each(*cx, decl, call, blk, sc, v);
|
||||||
}
|
}
|
||||||
ast::expr_for(?decl, ?seq, ?block) {
|
ast::expr_for(?decl, ?seq, ?blk) {
|
||||||
check_for(*cx, decl, seq, block, sc, v);
|
check_for(*cx, decl, seq, blk, sc, v);
|
||||||
}
|
}
|
||||||
ast::expr_path(?pt) {
|
ast::expr_path(?pt) {
|
||||||
check_var(*cx, ex, pt, ex.id, false, sc);
|
check_var(*cx, ex, pt, ex.id, false, sc);
|
||||||
@@ -326,7 +326,7 @@ fn arm_defnums(&ast::arm arm) -> node_id[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_for_each(&ctx cx, &@ast::local local, &@ast::expr call,
|
fn check_for_each(&ctx cx, &@ast::local local, &@ast::expr call,
|
||||||
&ast::block block, &scope sc, &vt[scope] v) {
|
&ast::block blk, &scope sc, &vt[scope] v) {
|
||||||
visit::visit_expr(call, sc, v);
|
visit::visit_expr(call, sc, v);
|
||||||
alt (call.node) {
|
alt (call.node) {
|
||||||
case (ast::expr_call(?f, ?args)) {
|
case (ast::expr_call(?f, ?args)) {
|
||||||
@@ -339,12 +339,12 @@ fn check_for_each(&ctx cx, &@ast::local local, &@ast::expr call,
|
|||||||
tys=data.unsafe_ts,
|
tys=data.unsafe_ts,
|
||||||
depends_on=deps(sc, data.root_vars),
|
depends_on=deps(sc, data.root_vars),
|
||||||
mutable ok=valid);
|
mutable ok=valid);
|
||||||
visit::visit_block(block, @(*sc + ~[new_sc]), v);
|
visit::visit_block(blk, @(*sc + ~[new_sc]), v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq, &ast::block block,
|
fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq, &ast::block blk,
|
||||||
&scope sc, &vt[scope] v) {
|
&scope sc, &vt[scope] v) {
|
||||||
visit::visit_expr(seq, sc, v);
|
visit::visit_expr(seq, sc, v);
|
||||||
auto defnum = local.node.id;
|
auto defnum = local.node.id;
|
||||||
@@ -374,7 +374,7 @@ fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq, &ast::block block,
|
|||||||
tys=unsafe,
|
tys=unsafe,
|
||||||
depends_on=deps(sc, root_def),
|
depends_on=deps(sc, root_def),
|
||||||
mutable ok=valid);
|
mutable ok=valid);
|
||||||
visit::visit_block(block, @(*sc + ~[new_sc]), v);
|
visit::visit_block(blk, @(*sc + ~[new_sc]), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_var(&ctx cx, &@ast::expr ex, &ast::path p, ast::node_id id,
|
fn check_var(&ctx cx, &@ast::expr ex, &ast::path p, ast::node_id id,
|
||||||
|
|||||||
@@ -446,14 +446,14 @@ fn trans_recv(&@block_ctxt bcx, &dest dest, &@ast::expr expr) -> @block_ctxt {
|
|||||||
ret bcx; // TODO
|
ret bcx; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trans_block(&@block_ctxt cx, &dest dest, &ast::block block)
|
fn trans_block(&@block_ctxt cx, &dest dest, &ast::block blk)
|
||||||
-> @block_ctxt {
|
-> @block_ctxt {
|
||||||
auto bcx = cx;
|
auto bcx = cx;
|
||||||
for each (@ast::local local in trans::block_locals(block)) {
|
for each (@ast::local local in trans::block_locals(blk)) {
|
||||||
bcx = trans::alloc_local(bcx, local).bcx;
|
bcx = trans::alloc_local(bcx, local).bcx;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (@ast::stmt stmt in block.node.stmts) {
|
for (@ast::stmt stmt in blk.node.stmts) {
|
||||||
bcx = trans_stmt(bcx, stmt);
|
bcx = trans_stmt(bcx, stmt);
|
||||||
|
|
||||||
// If we hit a terminator, control won't go any further so
|
// If we hit a terminator, control won't go any further so
|
||||||
@@ -461,7 +461,7 @@ fn trans_block(&@block_ctxt cx, &dest dest, &ast::block block)
|
|||||||
if trans::is_terminated(bcx) { ret bcx; }
|
if trans::is_terminated(bcx) { ret bcx; }
|
||||||
}
|
}
|
||||||
|
|
||||||
alt (block.node.expr) {
|
alt (blk.node.expr) {
|
||||||
some(?e) { bcx = trans_expr(bcx, dest, e); }
|
some(?e) { bcx = trans_expr(bcx, dest, e); }
|
||||||
none { /* no-op */ }
|
none { /* no-op */ }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1147,7 +1147,7 @@ mod writeback {
|
|||||||
}
|
}
|
||||||
fn keep_going(@wb_ctxt wbcx) -> bool { !wbcx.ignore && wbcx.success }
|
fn keep_going(@wb_ctxt wbcx) -> bool { !wbcx.ignore && wbcx.success }
|
||||||
|
|
||||||
fn resolve_type_vars_in_block(&@fn_ctxt fcx, &ast::block block) -> bool {
|
fn resolve_type_vars_in_block(&@fn_ctxt fcx, &ast::block blk) -> bool {
|
||||||
auto wbcx = @rec(fcx = fcx,
|
auto wbcx = @rec(fcx = fcx,
|
||||||
mutable ignore = false,
|
mutable ignore = false,
|
||||||
mutable success = true);
|
mutable success = true);
|
||||||
@@ -1163,7 +1163,7 @@ mod writeback {
|
|||||||
visit_pat_pre=bind visit_pat_pre(wbcx, _),
|
visit_pat_pre=bind visit_pat_pre(wbcx, _),
|
||||||
visit_local_pre=bind visit_local_pre(wbcx, _)
|
visit_local_pre=bind visit_local_pre(wbcx, _)
|
||||||
with walk::default_visitor());
|
with walk::default_visitor());
|
||||||
walk::walk_block(visit, block);
|
walk::walk_block(visit, blk);
|
||||||
ret wbcx.success;
|
ret wbcx.success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2598,14 +2598,14 @@ fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) {
|
|||||||
write::nil_ty(fcx.ccx.tcx, node_id);
|
write::nil_ty(fcx.ccx.tcx, node_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_block(&@fn_ctxt fcx, &ast::block block) {
|
fn check_block(&@fn_ctxt fcx, &ast::block blk) {
|
||||||
for (@ast::stmt s in block.node.stmts) { check_stmt(fcx, s); }
|
for (@ast::stmt s in blk.node.stmts) { check_stmt(fcx, s); }
|
||||||
alt (block.node.expr) {
|
alt (blk.node.expr) {
|
||||||
case (none) { write::nil_ty(fcx.ccx.tcx, block.node.id); }
|
case (none) { write::nil_ty(fcx.ccx.tcx, blk.node.id); }
|
||||||
case (some(?e)) {
|
case (some(?e)) {
|
||||||
check_expr(fcx, e);
|
check_expr(fcx, e);
|
||||||
auto ety = expr_ty(fcx.ccx.tcx, e);
|
auto ety = expr_ty(fcx.ccx.tcx, e);
|
||||||
write::ty_only_fixup(fcx, block.node.id, ety);
|
write::ty_only_fixup(fcx, blk.node.id, ety);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ fn fold_mac_(&mac m, ast_fold fld) -> mac {
|
|||||||
case (mac_embed_type(?ty)) {
|
case (mac_embed_type(?ty)) {
|
||||||
mac_embed_type(fld.fold_ty(ty))
|
mac_embed_type(fld.fold_ty(ty))
|
||||||
}
|
}
|
||||||
case (mac_embed_block(?block)) {
|
case (mac_embed_block(?blk)) {
|
||||||
mac_embed_block(fld.fold_block(block))
|
mac_embed_block(fld.fold_block(blk))
|
||||||
}
|
}
|
||||||
case (mac_ellipsis) { mac_ellipsis }
|
case (mac_ellipsis) { mac_ellipsis }
|
||||||
},
|
},
|
||||||
@@ -388,16 +388,16 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
|||||||
case (expr_while(?cond, ?body)) {
|
case (expr_while(?cond, ?body)) {
|
||||||
expr_while(fld.fold_expr(cond), fld.fold_block(body))
|
expr_while(fld.fold_expr(cond), fld.fold_block(body))
|
||||||
}
|
}
|
||||||
case (expr_for(?decl, ?expr, ?block)) {
|
case (expr_for(?decl, ?expr, ?blk)) {
|
||||||
expr_for(fld.fold_local(decl), fld.fold_expr(expr),
|
expr_for(fld.fold_local(decl), fld.fold_expr(expr),
|
||||||
fld.fold_block(block))
|
fld.fold_block(blk))
|
||||||
}
|
}
|
||||||
case (expr_for_each(?decl, ?expr, ?block)) {
|
case (expr_for_each(?decl, ?expr, ?blk)) {
|
||||||
expr_for_each(fld.fold_local(decl), fld.fold_expr(expr),
|
expr_for_each(fld.fold_local(decl), fld.fold_expr(expr),
|
||||||
fld.fold_block(block))
|
fld.fold_block(blk))
|
||||||
}
|
}
|
||||||
case (expr_do_while(?block, ?expr)) {
|
case (expr_do_while(?blk, ?expr)) {
|
||||||
expr_do_while(fld.fold_block(block), fld.fold_expr(expr))
|
expr_do_while(fld.fold_block(blk), fld.fold_expr(expr))
|
||||||
}
|
}
|
||||||
case (expr_alt(?expr, ?arms)) {
|
case (expr_alt(?expr, ?arms)) {
|
||||||
expr_alt(fld.fold_expr(expr), ivec::map(fld.fold_arm, arms))
|
expr_alt(fld.fold_expr(expr), ivec::map(fld.fold_arm, arms))
|
||||||
@@ -405,8 +405,8 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
|||||||
case (expr_fn(?f)) {
|
case (expr_fn(?f)) {
|
||||||
expr_fn(fld.fold_fn(f))
|
expr_fn(fld.fold_fn(f))
|
||||||
}
|
}
|
||||||
case (expr_block(?block)) {
|
case (expr_block(?blk)) {
|
||||||
expr_block(fld.fold_block(block))
|
expr_block(fld.fold_block(blk))
|
||||||
}
|
}
|
||||||
case (expr_move(?el, ?er)) {
|
case (expr_move(?el, ?er)) {
|
||||||
expr_move(fld.fold_expr(el), fld.fold_expr(er))
|
expr_move(fld.fold_expr(el), fld.fold_expr(er))
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ fn bad_expr_word_table() -> hashmap[str, ()] {
|
|||||||
words.insert("fn", ());
|
words.insert("fn", ());
|
||||||
words.insert("pred", ());
|
words.insert("pred", ());
|
||||||
words.insert("iter", ());
|
words.insert("iter", ());
|
||||||
|
words.insert("block", ());
|
||||||
words.insert("import", ());
|
words.insert("import", ());
|
||||||
words.insert("export", ());
|
words.insert("export", ());
|
||||||
words.insert("let", ());
|
words.insert("let", ());
|
||||||
@@ -1407,8 +1408,8 @@ fn parse_alt_expr(&parser p) -> @ast::expr {
|
|||||||
if (p.peek() == token::LPAREN) { parens = true; p.bump(); }
|
if (p.peek() == token::LPAREN) { parens = true; p.bump(); }
|
||||||
auto pats = parse_pats(p);
|
auto pats = parse_pats(p);
|
||||||
if (parens) { expect(p, token::RPAREN); }
|
if (parens) { expect(p, token::RPAREN); }
|
||||||
auto block = parse_block(p);
|
auto blk = parse_block(p);
|
||||||
arms += ~[rec(pats=pats, block=block)];
|
arms += ~[rec(pats=pats, block=blk)];
|
||||||
}
|
}
|
||||||
auto hi = p.get_hi_pos();
|
auto hi = p.get_hi_pos();
|
||||||
p.bump();
|
p.bump();
|
||||||
|
|||||||
@@ -601,7 +601,7 @@ fn print_possibly_embedded_block(&ps s, &ast::block blk, bool embedded,
|
|||||||
s.ann.post(ann_node);
|
s.ann.post(ann_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_if(&ps s, &@ast::expr test, &ast::block block,
|
fn print_if(&ps s, &@ast::expr test, &ast::block blk,
|
||||||
&option::t[@ast::expr] elseopt, bool chk) {
|
&option::t[@ast::expr] elseopt, bool chk) {
|
||||||
head(s, "if");
|
head(s, "if");
|
||||||
if (chk) {
|
if (chk) {
|
||||||
@@ -609,7 +609,7 @@ fn print_if(&ps s, &@ast::expr test, &ast::block block,
|
|||||||
}
|
}
|
||||||
print_expr(s, test);
|
print_expr(s, test);
|
||||||
space(s.s);
|
space(s.s);
|
||||||
print_block(s, block);
|
print_block(s, blk);
|
||||||
fn do_else(&ps s, option::t[@ast::expr] els) {
|
fn do_else(&ps s, option::t[@ast::expr] els) {
|
||||||
alt (els) {
|
alt (els) {
|
||||||
case (some(?_else)) {
|
case (some(?_else)) {
|
||||||
@@ -773,11 +773,11 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||||||
word_space(s, "as");
|
word_space(s, "as");
|
||||||
print_type(s, *ty);
|
print_type(s, *ty);
|
||||||
}
|
}
|
||||||
case (ast::expr_if(?test, ?block, ?elseopt)) {
|
case (ast::expr_if(?test, ?blk, ?elseopt)) {
|
||||||
print_if(s, test, block, elseopt, false);
|
print_if(s, test, blk, elseopt, false);
|
||||||
}
|
}
|
||||||
case (ast::expr_if_check(?test, ?block, ?elseopt)) {
|
case (ast::expr_if_check(?test, ?blk, ?elseopt)) {
|
||||||
print_if(s, test, block, elseopt, true);
|
print_if(s, test, blk, elseopt, true);
|
||||||
}
|
}
|
||||||
case (ast::expr_ternary(?test, ?then, ?els)) {
|
case (ast::expr_ternary(?test, ?then, ?els)) {
|
||||||
print_expr(s, test);
|
print_expr(s, test);
|
||||||
@@ -788,13 +788,13 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||||||
word_space(s, ":");
|
word_space(s, ":");
|
||||||
print_expr(s, els);
|
print_expr(s, els);
|
||||||
}
|
}
|
||||||
case (ast::expr_while(?test, ?block)) {
|
case (ast::expr_while(?test, ?blk)) {
|
||||||
head(s, "while");
|
head(s, "while");
|
||||||
print_expr(s, test);
|
print_expr(s, test);
|
||||||
space(s.s);
|
space(s.s);
|
||||||
print_block(s, block);
|
print_block(s, blk);
|
||||||
}
|
}
|
||||||
case (ast::expr_for(?decl, ?expr, ?block)) {
|
case (ast::expr_for(?decl, ?expr, ?blk)) {
|
||||||
head(s, "for");
|
head(s, "for");
|
||||||
popen(s);
|
popen(s);
|
||||||
print_for_decl(s, decl);
|
print_for_decl(s, decl);
|
||||||
@@ -803,9 +803,9 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||||||
print_expr(s, expr);
|
print_expr(s, expr);
|
||||||
pclose(s);
|
pclose(s);
|
||||||
space(s.s);
|
space(s.s);
|
||||||
print_block(s, block);
|
print_block(s, blk);
|
||||||
}
|
}
|
||||||
case (ast::expr_for_each(?decl, ?expr, ?block)) {
|
case (ast::expr_for_each(?decl, ?expr, ?blk)) {
|
||||||
head(s, "for each");
|
head(s, "for each");
|
||||||
popen(s);
|
popen(s);
|
||||||
print_for_decl(s, decl);
|
print_for_decl(s, decl);
|
||||||
@@ -814,12 +814,12 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||||||
print_expr(s, expr);
|
print_expr(s, expr);
|
||||||
pclose(s);
|
pclose(s);
|
||||||
space(s.s);
|
space(s.s);
|
||||||
print_block(s, block);
|
print_block(s, blk);
|
||||||
}
|
}
|
||||||
case (ast::expr_do_while(?block, ?expr)) {
|
case (ast::expr_do_while(?blk, ?expr)) {
|
||||||
head(s, "do");
|
head(s, "do");
|
||||||
space(s.s);
|
space(s.s);
|
||||||
print_block(s, block);
|
print_block(s, blk);
|
||||||
space(s.s);
|
space(s.s);
|
||||||
word_space(s, "while");
|
word_space(s, "while");
|
||||||
print_expr(s, expr);
|
print_expr(s, expr);
|
||||||
@@ -853,14 +853,14 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||||||
space(s.s);
|
space(s.s);
|
||||||
print_block(s, f.body);
|
print_block(s, f.body);
|
||||||
}
|
}
|
||||||
case (ast::expr_block(?block)) {
|
case (ast::expr_block(?blk)) {
|
||||||
// containing cbox, will be closed by print-block at }
|
// containing cbox, will be closed by print-block at }
|
||||||
|
|
||||||
cbox(s, indent_unit);
|
cbox(s, indent_unit);
|
||||||
// head-box, will be closed by print-block after {
|
// head-box, will be closed by print-block after {
|
||||||
|
|
||||||
ibox(s, 0u);
|
ibox(s, 0u);
|
||||||
print_block(s, block);
|
print_block(s, blk);
|
||||||
}
|
}
|
||||||
case (ast::expr_move(?lhs, ?rhs)) {
|
case (ast::expr_move(?lhs, ?rhs)) {
|
||||||
print_expr(s, lhs);
|
print_expr(s, lhs);
|
||||||
|
|||||||
Reference in New Issue
Block a user