Skip to content

Commit 74cb950

Browse files
tohavagraydon
authored andcommitted
Closed issue 154 - prevents compiler from compiliing a line to zero statements
1 parent b970563 commit 74cb950

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/boot/fe/item.ml

+10-1
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,21 @@ and parse_auto_slot_and_init
148148
let stmts = ctxt "slot, ident and init: init" (parse_init lval) ps in
149149
(stmts, slot_auto, ident)
150150

151+
152+
and parse_stmts (ps:pstate) : Ast.stmt array =
153+
let arr = parse_stmts_including_none ps in
154+
if (Array.length arr) == 0 then
155+
raise (err "statement does nothing" ps);
156+
arr
157+
158+
159+
151160
(*
152161
* We have no way to parse a single Ast.stmt; any incoming syntactic statement
153162
* may desugar to N>1 real Ast.stmts
154163
*)
155164

156-
and parse_stmts (ps:pstate) : Ast.stmt array =
165+
and parse_stmts_including_none (ps:pstate) : Ast.stmt array =
157166
let apos = lexpos ps in
158167

159168
let ensure_mutable slot =

src/test/compile-fail/does-nothing.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// error-pattern: does nothing
2+
fn main() {
3+
log "doing";
4+
this_does_nothing_what_the;
5+
log "boing";
6+
}
7+

0 commit comments

Comments
 (0)