From 7c4f8cb45924326e21547d19cbed683115657616 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 20 Apr 2011 12:11:01 -0700 Subject: Further work on typestate_check Lots of work on typestate_check, seems to get a lot of the way through checking the standard library. * Added for, for_each, assign_op, bind, cast, put, check, break, and cont. (I'm not sure break and cont are actually handled correctly.) * Fixed side-effect bug in seq_preconds so that unioning the preconditions of a sequence of statements or expressions is handled correctly. * Pass poststate correctly through a stmt_decl. * Handle expr_ret and expr_fail properly (after execution of a ret or fail, everything is true -- this is needed to handle ifs and alts where one branch is a ret or fail) * Fixed bug in set_prestate_ann where a thing that needed to be mutated wasn't getting passed as an alias * Fixed bug in how expr_alt was treated (zero is not the identity for intersect, who knew, right?) * Update logging to reflect log_err vs. log * Fixed find_locals so as to return all local decls and exclude function arguments. * Make union_postconds work on an empty vector (needed to handle empty blocks correctly) * Added _vec.cat_options, which takes a list of option[T] to a list of T, ignoring any Nones * Added two test cases. --- src/test/run-pass/use-uninit-alt.rs | 21 +++++++++++++++++++++ src/test/run-pass/use-uninit-alt2.rs | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/test/run-pass/use-uninit-alt.rs create mode 100644 src/test/run-pass/use-uninit-alt2.rs (limited to 'src/test') diff --git a/src/test/run-pass/use-uninit-alt.rs b/src/test/run-pass/use-uninit-alt.rs new file mode 100644 index 00000000..a7c77bba --- /dev/null +++ b/src/test/run-pass/use-uninit-alt.rs @@ -0,0 +1,21 @@ +fn foo[T](&myoption[T] o) -> int { + let int x = 5; + + alt (o) { + case (none[T]) { } + case (some[T](?t)) { + x += 1; + } + } + + ret x; +} + +tag myoption[T] { + none; + some(T); +} + +fn main() { + log(5); +} \ No newline at end of file diff --git a/src/test/run-pass/use-uninit-alt2.rs b/src/test/run-pass/use-uninit-alt2.rs new file mode 100644 index 00000000..36514d13 --- /dev/null +++ b/src/test/run-pass/use-uninit-alt2.rs @@ -0,0 +1,21 @@ +fn foo[T](&myoption[T] o) -> int { + let int x; + + alt (o) { + case (none[T]) { fail; } + case (some[T](?t)) { + x = 5; + } + } + + ret x; +} + +tag myoption[T] { + none; + some(T); +} + +fn main() { + log(5); +} \ No newline at end of file -- cgit v1.2.3