Skip to content

Commit 7c7559e

Browse files
committed
Disallow variable names that shadow tags in scope
Now, if you have a tag named "foo", a variable declaration like "let foo..." is illegal. This change makes it possible to eliminate the '.' after a nullary tag pattern in an alt (but I'll be doing that in a future commit) -- as now it's always obvious whether a name refers to a tag or a new declared variable. resolve implements this change -- all the other changes are just to get rid of existing code that declares variables that shadow tag names.
1 parent da519c8 commit 7c7559e

File tree

7 files changed

+170
-69
lines changed

7 files changed

+170
-69
lines changed

src/comp/metadata/tydecode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
305305
}
306306

307307
fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt {
308-
let mut;
308+
let m;
309309
alt peek(st) as char {
310-
'm' { next(st); mut = ast::mut; }
311-
'?' { next(st); mut = ast::maybe_mut; }
312-
_ { mut = ast::imm; }
310+
'm' { next(st); m = ast::mut; }
311+
'?' { next(st); m = ast::maybe_mut; }
312+
_ { m = ast::imm; }
313313
}
314-
ret {ty: parse_ty(st, conv), mut: mut};
314+
ret {ty: parse_ty(st, conv), mut: m};
315315
}
316316

317317
fn parse_def(st: @pstate, conv: conv_did) -> ast::def_id {

src/comp/middle/last_use.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,18 @@ fn join_branches(branches: [set]) -> set {
220220
i += 1u;
221221
for {def, exprs} in set {
222222
if !vec::any(found, {|v| v.def == def}) {
223-
let j = i, ne = exprs;
223+
let j = i, nne = exprs;
224224
while j < l {
225225
for {def: d2, exprs} in branches[j] {
226226
if d2 == def {
227227
list::iter(exprs) {|e|
228-
if !list::has(ne, e) { ne = cons(e, @ne); }
228+
if !list::has(nne, e) { nne = cons(e, @nne); }
229229
}
230230
}
231231
}
232232
j += 1u;
233233
}
234-
found += [{def: def, exprs: ne}];
234+
found += [{def: def, exprs: nne}];
235235
}
236236
}
237237
}

0 commit comments

Comments
 (0)