aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOr Brostovski <[email protected]>2010-08-28 15:22:20 +0300
committerGraydon Hoare <[email protected]>2010-09-30 13:40:34 -0700
commit74cb9508cd122b7863f179c69c406e0f47572354 (patch)
tree6ba22a1cbe7aed3eecf81b901029a05ca8b25088 /src
parentPatchwork of attempted fixes to effect system and gc system; eventually give ... (diff)
downloadrust-74cb9508cd122b7863f179c69c406e0f47572354.tar.xz
rust-74cb9508cd122b7863f179c69c406e0f47572354.zip
Closed issue 154 - prevents compiler from compiliing a line to zero statements
Diffstat (limited to 'src')
-rw-r--r--src/boot/fe/item.ml11
-rw-r--r--src/test/compile-fail/does-nothing.rs7
2 files changed, 17 insertions, 1 deletions
diff --git a/src/boot/fe/item.ml b/src/boot/fe/item.ml
index 5340d262..3d3bf84f 100644
--- a/src/boot/fe/item.ml
+++ b/src/boot/fe/item.ml
@@ -148,12 +148,21 @@ and parse_auto_slot_and_init
let stmts = ctxt "slot, ident and init: init" (parse_init lval) ps in
(stmts, slot_auto, ident)
+
+and parse_stmts (ps:pstate) : Ast.stmt array =
+ let arr = parse_stmts_including_none ps in
+ if (Array.length arr) == 0 then
+ raise (err "statement does nothing" ps);
+ arr
+
+
+
(*
* We have no way to parse a single Ast.stmt; any incoming syntactic statement
* may desugar to N>1 real Ast.stmts
*)
-and parse_stmts (ps:pstate) : Ast.stmt array =
+and parse_stmts_including_none (ps:pstate) : Ast.stmt array =
let apos = lexpos ps in
let ensure_mutable slot =
diff --git a/src/test/compile-fail/does-nothing.rs b/src/test/compile-fail/does-nothing.rs
new file mode 100644
index 00000000..805d3142
--- /dev/null
+++ b/src/test/compile-fail/does-nothing.rs
@@ -0,0 +1,7 @@
+// error-pattern: does nothing
+fn main() {
+ log "doing";
+ this_does_nothing_what_the;
+ log "boing";
+}
+