From 844fe207206b6708f2a7e05214857c92c4b7d28b Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 27 Apr 2011 14:55:55 -0700 Subject: Fix some nested patterns in rustc In rustc, nested patterns were potentially matching when they shouldn't match, because a loop index wasn't being incremented. Fixed it and added one test case. --- src/test/run-pass/nested-pattern.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/run-pass/nested-pattern.rs (limited to 'src/test') diff --git a/src/test/run-pass/nested-pattern.rs b/src/test/run-pass/nested-pattern.rs new file mode 100644 index 00000000..e59c2dd5 --- /dev/null +++ b/src/test/run-pass/nested-pattern.rs @@ -0,0 +1,29 @@ +// a bug was causing this to complain about leaked memory on exit + +use std; +import std.option; +import std.option.some; +import std.option.none; + +tag t { + foo(int, uint); + bar(int, option.t[int]); +} + +fn nested(t o) { + + alt (o) { + case (bar(?i, some[int](_))) { + log_err "wrong pattern matched"; + fail; + } + case (_) { + log_err "succeeded"; + } + } + +} + +fn main() { + nested (bar (1, none[int])); +} \ No newline at end of file -- cgit v1.2.3