Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ml-proto/spec/check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ and check_exprs c ts es =
with Invalid_argument _ -> error (Source.ats es) "arity mismatch"

and check_expr_opt c et eo at =
match eo with
| Some e -> check_expr c et e
| None -> check_type None et at
match et, eo with
| Some t, Some e -> check_expr c et e
| None, None -> ()
| _ -> error at "arity mismatch"

and check_literal c et l =
check_type (Some (type_value l.it)) et l.at
Expand Down
3 changes: 2 additions & 1 deletion ml-proto/test/labels.wast
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(loop $exit $cont
(set_local $i (i32.add (get_local $i) (i32.const 1)))
(if (i32.eq (get_local $i) (i32.const 5))
(br $cont (i32.const -1))
(br $cont)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps also add an assert_invalid test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

)
(if (i32.eq (get_local $i) (i32.const 8))
(br $exit (get_local $i))
Expand Down Expand Up @@ -78,3 +78,4 @@
(assert_return (invoke "return" (i32.const 1)) (i32.const 2))
(assert_return (invoke "return" (i32.const 2)) (i32.const 2))

(assert_invalid (module (func (loop $l (br $l (i32.const 0))))) "arity mismatch")
2 changes: 1 addition & 1 deletion ml-proto/test/switch.wast
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(case $2) ;; fallthrough
(case $3 (set_local $j (i32.sub (i32.const 0) (get_local $i))) (br 0))
(case $4 (br 0))
(case $5 (br 0 (set_local $j (i32.const 101))))
(case $5 (set_local $j (i32.const 101)) (br 0))
(case $6 (set_local $j (i32.const 101))) ;; fallthrough
(case $default (set_local $j (i32.const 102)))
(case $7)
Expand Down