]> git.lizzy.rs Git - rust.git/commitdiff
add unit test for match var hygiene
authorJohn Clements <clements@racket-lang.org>
Tue, 24 Jun 2014 23:34:03 +0000 (16:34 -0700)
committerJohn Clements <clements@racket-lang.org>
Wed, 25 Jun 2014 21:16:12 +0000 (14:16 -0700)
src/libsyntax/ext/expand.rs

index bf68538d656068d97ded5fee19379b37fb58c1c3..c2e13a53b1e0eaa178a0f788a784b5ad5f4c33f7 100644 (file)
@@ -1254,6 +1254,18 @@ fn a(){g!(z)}",
             0)
     }
 
+    // FIXME #9384, match variable hygiene. Should expand into
+    // fn z() {match 8 {x_1 => {match 9 {x_2 | x_2 => x_2 + x_1}}}}
+    #[test] fn issue_9384(){
+        run_renaming_test(
+            &("macro_rules! bad_macro (($ex:expr) => ({match 9 {x | x => x + $ex}}))
+              fn z() {match 8 {x => bad_macro!(_x)}}",
+              // NB: the third "binding" is the repeat of the second one.
+              vec!(vec!(1),vec!(0),vec!(0)),
+              true),
+            0)
+    }
+
     // create a really evil test case where a $x appears inside a binding of $x
     // but *shouldnt* bind because it was inserted by a different macro....
     // can't write this test case until we have macro-generating macros.