From 58433a9c5a6a6942d9dc4a97e0228dc4bd6ad663 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Thu, 26 Nov 2026 07:13:15 +0800 Subject: [PATCH 1/4] [test] Add cases for a NUL byte in a line comment A line comment can hold any character except a line break, so a NUL byte is valid. Add cases in plain text and inside an annotation. Each module exports a function after the comment and invokes it, so the test fails if the lexer skips the rest of the input. --- test/core/comments.wast | Bin 1316 -> 1637 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/core/comments.wast b/test/core/comments.wast index 5ef64a6c1e60e898c86f51a53dcb11201e5025f8..d71c094066756bc646bf1d4ebaf8eb3f57f62f0e 100644 GIT binary patch delta 252 zcmZ3&^^|9W3Tp(HwY7qyf?ueQLQ-W(szPR-LZU)WW?rg7a(-@ZYF>$sLSjyFK2W?k zGbL3a5h$IPmtT@tl9`{!rIDMTQks*hP*|E@lFFr^pae84F~-0kDaIgivK)(;QjC(O zf<{qlacNG8LZ-11kOL(3lJoP5OB4(>HI=wDC(mb*G6JbWk-#)r!y!=t*>qVJalED* N!A%!JH619y1pudlNG1RP delta 7 OcmaFLvxIAd3M&8%O9FWS From a09e9bcf041c08c6baf5f86fc916263b9b3a50c5 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Thu, 26 Nov 2026 07:13:15 +0800 Subject: [PATCH 2/4] [test] Add cases for invalid UTF-8 in comments The source text must be valid UTF-8, also inside comments. Add cases for a line comment, a block comment and a nested block comment. --- test/core/comments.wast | Bin 1637 -> 1910 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/core/comments.wast b/test/core/comments.wast index d71c094066756bc646bf1d4ebaf8eb3f57f62f0e..290034492b878df259629e2fd093855dc62bdee7 100644 GIT binary patch delta 283 zcmaFL^NnvqDqB65wY7qCer|4RUP-Y+ZfS9eLQ<+iSz=CRib80Jo2~_yMq+VsYEemi zZemVaeo<~}ih@RNeoARhszPCDeo3l=lC^bAT3U=jqDES2Ub3c=rh*beDcA^w)V$>U tl+3(zB~1*|>M@Md02ybkNtS6?3{%jsR)|S9R Date: Thu, 26 Nov 2026 07:13:15 +0800 Subject: [PATCH 3/4] [test] Add cases for unclosed block comments A block comment must end with ";)". Add cases for an unclosed comment at the start of the input, after a field, and inside an annotation. --- test/core/annotations.wast | 1 + test/core/comments.wast | Bin 1910 -> 2058 bytes 2 files changed, 1 insertion(+) diff --git a/test/core/annotations.wast b/test/core/annotations.wast index 181e59a231..ead48a4975 100644 --- a/test/core/annotations.wast +++ b/test/core/annotations.wast @@ -90,6 +90,7 @@ (assert_malformed (module quote "(@x \"") "unclosed string") (assert_malformed (module quote "(@x \")") "unclosed string") +(assert_malformed (module quote "(@a (; x") "unclosed comment") (assert_malformed (module quote "((@a)@b)") "unknown operator") (assert_malformed (module quote "(func $(@a))") "empty identifier") diff --git a/test/core/comments.wast b/test/core/comments.wast index 290034492b878df259629e2fd093855dc62bdee7..70a1b6f3fe34432f94860e7b8b0dac145f74e5ab 100644 GIT binary patch delta 92 zcmeyy*Cnu_j9rw=+FBtrFF7Z_I5kBfIX^cyHLs+2vI4uRh?1s)QYo6u Date: Thu, 26 Nov 2026 07:13:15 +0800 Subject: [PATCH 4/4] [test] Add a case for a control character in a string A string literal cannot hold a raw character below U+20. Add a case with U+01 in a data string. --- test/core/token.wast | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/core/token.wast b/test/core/token.wast index 44e41f22bc..496bd2d501 100644 --- a/test/core/token.wast +++ b/test/core/token.wast @@ -302,3 +302,10 @@ ) "unknown operator" ) + +;; Control characters in strings + +(assert_malformed + (module quote "(memory 1) (data (i32.const 0) \"a\01b\")") + "illegal control character" +)