Skip to content

Commit 12c14d9

Browse files
committed
---
yaml --- r: 10614 b: refs/heads/snap-stage3 c: 76d6120 h: refs/heads/master v: v3
1 parent 0b284fb commit 12c14d9

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 6db7843f46afd5cd905b2e3a4266a23c4bb41ef1
4+
refs/heads/snap-stage3: 76d6120e521b6546c54722e0dabfe8e73a5d6e73
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/rustc/middle/resolve.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ fn visit_item_with_scope(e: @env, i: @ast::item,
573573
}
574574
ast::item_class(tps, ifaces, members, ctor, m_dtor, _) {
575575
v.visit_ty_params(tps, sc, v);
576-
// Can maybe skip this now that we require self on class fields
577576
let class_scope = @cons(scope_item(i), sc);
578577
/* visit the constructor... */
579578
let ctor_scope = @cons(scope_method(ctor.node.self_id, tps),
@@ -1061,7 +1060,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
10611060
}
10621061
ast::item_class(tps, _, members, ctor, _, _) {
10631062
if ns == ns_type {
1064-
ret lookup_in_ty_params(e, name, tps);
1063+
ret lookup_in_ty_params(e, name, tps);
10651064
}
10661065
if ns == ns_val && name == it.ident {
10671066
ret some(ast::def_fn(local_def(ctor.node.id),
@@ -1317,13 +1316,14 @@ fn found_def_item(i: @ast::item, ns: namespace) -> option<def> {
13171316
alt i.node {
13181317
ast::item_const(*) {
13191318
if ns == ns_val {
1320-
ret some(ast::def_const(local_def(i.id))); }
1319+
ret some(ast::def_const(local_def(i.id)));
1320+
}
13211321
}
13221322
ast::item_fn(decl, _, _) {
1323-
if ns == ns_val {
1323+
if ns == ns_val {
13241324
ret some(ast::def_fn(local_def(i.id), decl.purity));
1325-
}
1326-
}
1325+
}
1326+
}
13271327
ast::item_mod(_) {
13281328
if ns == ns_module { ret some(ast::def_mod(local_def(i.id))); }
13291329
}
@@ -1342,9 +1342,16 @@ fn found_def_item(i: @ast::item, ns: namespace) -> option<def> {
13421342
_ { }
13431343
}
13441344
}
1345-
ast::item_class(*) {
1346-
if ns == ns_type {
1347-
ret some(ast::def_class(local_def(i.id)));
1345+
ast::item_class(_, _, _members, ct, _, _) {
1346+
alt ns {
1347+
ns_type {
1348+
ret some(ast::def_class(local_def(i.id)));
1349+
}
1350+
ns_val {
1351+
ret some(ast::def_fn(local_def(ct.node.id),
1352+
ast::impure_fn));
1353+
}
1354+
ns_module { }
13481355
}
13491356
}
13501357
ast::item_impl(*) { /* ??? */ }
@@ -1653,14 +1660,6 @@ fn index_mod(md: ast::_mod) -> mod_index {
16531660
ast::item_class(tps, _, items, ctor, _, _) {
16541661
// add the class name itself
16551662
add_to_index(index, it.ident, mie_item(it));
1656-
// add the constructor decl
1657-
add_to_index(index, it.ident,
1658-
mie_item(@{ident: it.ident, attrs: [],
1659-
id: ctor.node.id,
1660-
node:
1661-
item_fn(ctor.node.dec, tps, ctor.node.body),
1662-
vis: ast::public,
1663-
span: ctor.node.body.span}));
16641663
}
16651664
}
16661665
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
fn main() {
2+
3+
class b {
4+
let i: int;
5+
fn do_stuff() -> int { ret 37; }
6+
new(i:int) { self.i = i; }
7+
}
8+
9+
// fn b(x:int) -> int { fail; }
10+
11+
let z = b(42);
12+
assert(z.i == 42);
13+
assert(z.do_stuff() == 37);
14+
15+
}

0 commit comments

Comments
 (0)