Skip to content

Commit 99cb43e

Browse files
committed
---
yaml --- r: 152844 b: refs/heads/try2 c: bcdcaea h: refs/heads/master v: v3
1 parent 3456722 commit 99cb43e

File tree

3 files changed

+60
-7
lines changed

3 files changed

+60
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c8558f2300a01a813f66f54d2ff6ee8ef918b3bb
8+
refs/heads/try2: bcdcaea5728db8003b1ad781490d782465658589
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libsyntax/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ impl Arg {
835835
}
836836
}
837837

838+
// represents the header (not the body) of a function declaration
838839
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
839840
pub struct FnDecl {
840841
pub inputs: Vec<Arg>,

branches/try2/src/libsyntax/ext/expand.rs

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,9 @@ fn expand_non_macro_stmt(s: &Stmt, fld: &mut MacroExpander)
658658
}
659659
}
660660

661-
// a visitor that extracts the pat_ident paths
661+
// a visitor that extracts the pat_ident (binding) paths
662662
// from a given thingy and puts them in a mutable
663-
// array (passed in to the traversal)
663+
// array (passed in to the traversal).
664664
#[deriving(Clone)]
665665
pub struct NewNameFinderContext {
666666
ident_accumulator: Vec<ast::Ident> ,
@@ -1026,7 +1026,7 @@ mod test {
10261026
use parse;
10271027
use parse::token;
10281028
use util::parser_testing::{string_to_parser};
1029-
use util::parser_testing::{string_to_pat, strs_to_idents};
1029+
use util::parser_testing::{string_to_pat, string_to_crate, strs_to_idents};
10301030
use visit;
10311031
use visit::Visitor;
10321032

@@ -1059,7 +1059,7 @@ mod test {
10591059
}
10601060

10611061
// return a visitor that extracts the paths
1062-
// from a given pattern and puts them in a mutable
1062+
// from a given thingy and puts them in a mutable
10631063
// array (passed in to the traversal)
10641064
pub fn new_path_finder(paths: Vec<ast::Path> ) -> NewPathExprFinderContext {
10651065
NewPathExprFinderContext {
@@ -1188,7 +1188,7 @@ mod test {
11881188
// The comparisons are done post-mtwt-resolve, so we're comparing renamed
11891189
// names; differences in marks don't matter any more.
11901190
//
1191-
// oog... I also want tests that check "binding-identifier-=?". That is,
1191+
// oog... I also want tests that check "bound-identifier-=?". That is,
11921192
// not just "do these have the same name", but "do they have the same
11931193
// name *and* the same marks"? Understanding this is really pretty painful.
11941194
// in principle, you might want to control this boolean on a per-varref basis,
@@ -1217,12 +1217,55 @@ mod test {
12171217
("macro_rules! letty(($x:ident) => (let $x = 15;))
12181218
macro_rules! user(($x:ident) => ({letty!($x); $x}))
12191219
fn main() -> int {user!(z)}",
1220-
vec!(vec!(0)), false));
1220+
vec!(vec!(0)), false)
1221+
);
12211222
for (idx,s) in tests.iter().enumerate() {
12221223
run_renaming_test(s,idx);
12231224
}
12241225
}
12251226

1227+
// no longer a fixme #8062: this test exposes a *potential* bug; our system does
1228+
// not behave exactly like MTWT, but a conversation with Matthew Flatt
1229+
// suggests that this can only occur in the presence of local-expand, which
1230+
// we have no plans to support. ... unless it's needed for item hygiene....
1231+
#[ignore]
1232+
#[test] fn issue_8062(){
1233+
run_renaming_test(
1234+
&("fn main() {let hrcoo = 19; macro_rules! getx(()=>(hrcoo)); getx!();}",
1235+
vec!(vec!(0)), true), 0)
1236+
}
1237+
1238+
// FIXME #6994:
1239+
// the z flows into and out of two macros (g & f) along one path, and one
1240+
// (just g) along the other, so the result of the whole thing should
1241+
// be "let z_123 = 3; z_123"
1242+
#[ignore]
1243+
#[test] fn issue_6994(){
1244+
run_renaming_test(
1245+
&("macro_rules! g (($x:ident) =>
1246+
({macro_rules! f(($y:ident)=>({let $y=3;$x}));f!($x)}))
1247+
fn a(){g!(z)}",
1248+
vec!(vec!(0)),false),
1249+
0)
1250+
}
1251+
1252+
// create a really evil test case where a $x appears inside a binding of $x
1253+
// but *shouldnt* bind because it was inserted by a different macro....
1254+
// can't write this test case until we have macro-generating macros.
1255+
1256+
// FIXME #9383 : lambda var hygiene
1257+
// interesting... can't even write this test, yet, because the name-finder
1258+
// only finds pattern vars. Time to upgrade test framework.
1259+
/*#[test]
1260+
fn issue_9383(){
1261+
run_renaming_test(
1262+
&("macro_rules! bad_macro (($ex:expr) => ({(|_x| { $ex }) (9) }))
1263+
fn takes_x(_x : int) { assert_eq!(bad_macro!(_x),8); }
1264+
fn main() { takes_x(8); }",
1265+
vec!(vec!()),false),
1266+
0)
1267+
}*/
1268+
12261269
// run one of the renaming tests
12271270
fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
12281271
let invalid_name = token::special_idents::invalid.name;
@@ -1358,4 +1401,13 @@ foo_module!()
13581401
strs_to_idents(vec!("a","c","b","d")));
13591402
}
13601403

1404+
#[test]
1405+
fn pat_idents_2(){
1406+
let the_crate = string_to_crate("fn main (a : int) -> int {|b| {a + b} }".to_string());
1407+
let mut pat_idents = new_name_finder(Vec::new());
1408+
pat_idents.visit_mod(&the_crate.module, the_crate.span, ast::CRATE_NODE_ID, ());
1409+
assert_eq!(pat_idents.ident_accumulator,
1410+
strs_to_idents(vec!("a","b")));
1411+
}
1412+
13611413
}

0 commit comments

Comments
 (0)