diff --git a/proposals/annotations/token.wast b/proposals/annotations/token.wast new file mode 100644 index 0000000..44e41f2 --- /dev/null +++ b/proposals/annotations/token.wast @@ -0,0 +1,304 @@ +;; Test tokenization + +(assert_malformed + (module quote "(func (drop (i32.const0)))") + "unknown operator" +) +(assert_malformed + (module quote "(func br 0drop)") + "unknown operator" +) + + +;; Tokens can be delimited by parentheses + +(module + (func(nop)) +) +(module + (func (nop)nop) +) +(module + (func nop(nop)) +) +(module + (func(nop)(nop)) +) +(module + (func $f(nop)) +) +(module + (func br 0(nop)) +) +(module + (table 1 funcref) + (func) + (elem (i32.const 0)0) +) +(module + (table 1 funcref) + (func $f) + (elem (i32.const 0)$f) +) +(module + (memory 1) + (data (i32.const 0)"a") +) +(module + (import "spectest" "print"(func)) +) + + +;; Tokens can be delimited by comments + +(module + (func;;bla + ) +) +(module + (func (nop);;bla + ) +) +(module + (func nop;;bla + ) +) +(module + (func $f;;bla + ) +) +(module + (func br 0;;bla + ) +) +(module + (data "a";;bla + ) +) + + +;; Space required between symbols and non-parenthesis tokens + +(module + (func (block $l (i32.const 0) (br_table 0 $l))) +) +(assert_malformed + (module quote + "(func (block $l (i32.const 0) (br_table 0$l)))" + ) + "unknown operator" +) +(assert_malformed + (module quote + "(func (block $l (i32.const 0) (br_table 0$\"l\")))" + ) + "unknown operator" +) + +(module + (func (block $l (i32.const 0) (br_table $l 0))) +) +(assert_malformed + (module quote + "(func (block $l (i32.const 0) (br_table $l0)))" + ) + "unknown label" +) +(assert_malformed + (module quote + "(func (block $l (i32.const 0) (br_table $\"l\"0)))" + ) + "unknown operator" +) + +(module + (func (block $l (i32.const 0) (br_table $l $l))) +) +(assert_malformed + (module quote + "(func (block $l (i32.const 0) (br_table $l$l)))" + ) + "unknown label" +) +(assert_malformed + (module quote + "(func (block $l (i32.const 0) (br_table $\"l\"$l)))" + ) + "unknown operator" +) + +(module + (func (block $l0 (i32.const 0) (br_table $l0))) +) +(module + (func (block $l$l (i32.const 0) (br_table $l$l))) +) + + +;; Space required between strings and non-parenthesis tokens + +(module + (data "a") +) +(assert_malformed + (module quote + "(data\"a\")" + ) + "unknown operator" +) + +(module + (data $l "a") +) +(assert_malformed + (module quote + "(data $l\"a\")" + ) + "unknown operator" +) + +(module + (data $l " a") +) +(assert_malformed + (module quote + "(data $l\" a\")" + ) + "unknown operator" +) + +(module + (data $l "a ") +) +(assert_malformed + (module quote + "(data $l\"a \")" + ) + "unknown operator" +) + +(module + (data $l "a " "b") +) +(assert_malformed + (module quote + "(data $l\"a \"\"b\")" + ) + "unknown operator" +) + +(module + (data $l "") +) +(assert_malformed + (module quote + "(data $l\"\")" + ) + "unknown operator" +) + +(module + (data $l " ") +) +(assert_malformed + (module quote + "(data $l\" \")" + ) + "unknown operator" +) + +(module + (data $l " ") +) +(assert_malformed + (module quote + "(data $l\" \")" + ) + "unknown operator" +) + +(module + (data "a" "b") +) +(assert_malformed + (module quote + "(data \"a\"\"b\")" + ) + "unknown operator" +) + +(module + (data "a" " b") +) +(assert_malformed + (module quote + "(data \"a\"\" b\")" + ) + "unknown operator" +) + +(module + (data "a " "b") +) +(assert_malformed + (module quote + "(data \"a \"\"b\")" + ) + "unknown operator" +) + +(module + (data "" "") +) +(assert_malformed + (module quote + "(data \"\"\"\")" + ) + "unknown operator" +) + +(module + (data "" " ") +) +(assert_malformed + (module quote + "(data \"\"\" \")" + ) + "unknown operator" +) + +(module + (data " " "") +) +(assert_malformed + (module quote + "(data \" \"\"\")" + ) + "unknown operator" +) + + +(assert_malformed + (module quote + "(func \"a\"x)" + ) + "unknown operator" +) +(assert_malformed + (module quote + "(func \"a\"0)" + ) + "unknown operator" +) +(assert_malformed + (module quote + "(func 0\"a\")" + ) + "unknown operator" +) +(assert_malformed + (module quote + "(func \"a\"$x)" + ) + "unknown operator" +) diff --git a/proposals/exception-handling/try_table.wast b/proposals/exception-handling/try_table.wast index e64b6c1..43ae52c 100644 --- a/proposals/exception-handling/try_table.wast +++ b/proposals/exception-handling/try_table.wast @@ -238,6 +238,10 @@ ) ) ) + + (func (export "try-with-param") + (i32.const 0) (try_table (param i32) (drop)) + ) ) (assert_return (invoke "simple-throw-catch" (i32.const 0)) (i32.const 23)) @@ -294,6 +298,8 @@ (assert_exception (invoke "return-call-in-try-catch")) (assert_exception (invoke "return-call-indirect-in-try-catch")) +(assert_return (invoke "try-with-param")) + (module (func $imported-throw (import "test" "throw")) (tag $e0) diff --git a/proposals/gc/call_ref.wast b/proposals/gc/call_ref.wast index da480a7..aa9ac7b 100644 --- a/proposals/gc/call_ref.wast +++ b/proposals/gc/call_ref.wast @@ -206,3 +206,13 @@ ) "type mismatch" ) + +(assert_invalid + (module + (type $t (func)) + (func $f (param $r funcref) + (call_ref $t (local.get $r)) + ) + ) + "type mismatch" +) diff --git a/proposals/gc/return_call.wast b/proposals/gc/return_call.wast index 2f91f4d..b9e8f8f 100644 --- a/proposals/gc/return_call.wast +++ b/proposals/gc/return_call.wast @@ -188,7 +188,15 @@ ) "type mismatch" ) - +(assert_invalid + (module + (func $f (result i32 i32) unreachable) + (func (result i32) + return_call $f + ) + ) + "type mismatch" +) ;; Unbound function diff --git a/proposals/gc/return_call_indirect.wast b/proposals/gc/return_call_indirect.wast index acf0a72..aa158be 100644 --- a/proposals/gc/return_call_indirect.wast +++ b/proposals/gc/return_call_indirect.wast @@ -508,7 +508,17 @@ ) "type mismatch" ) - +(assert_invalid + (module + (type $ty (func (result i32 i32))) + (import "env" "table" (table $table 0 funcref)) + (func (param i32) (result i32) + local.get 0 + return_call_indirect $table (type $ty) + ) + ) + "type mismatch" +) ;; Unbound type diff --git a/proposals/gc/return_call_ref.wast b/proposals/gc/return_call_ref.wast index 2b495f4..5f5a7cb 100644 --- a/proposals/gc/return_call_ref.wast +++ b/proposals/gc/return_call_ref.wast @@ -374,3 +374,24 @@ ) "type mismatch" ) + +(assert_invalid + (module + (type $t (func)) + (func $f (param $r funcref) + (return_call_ref $t (local.get $r)) + ) + ) + "type mismatch" +) + +(assert_invalid + (module + (type $ty (func (result i32 i32))) + (func (param (ref $ty)) (result i32) + local.get 0 + return_call_ref $ty + ) + ) + "type mismatch" +)