From a731d1f36c8c46233d4be6a543354a108b7866d0 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Thu, 26 Nov 2026 07:10:20 +0800 Subject: [PATCH 1/2] [test] Add cases for the \r and \' escapes No test uses the \r and \' string escapes. Export a function under each name and invoke it by an independent spelling of the same name. --- test/core/names.wast | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/core/names.wast b/test/core/names.wast index 9c53234cf0..68b2dd1186 100644 --- a/test/core/names.wast +++ b/test/core/names.wast @@ -1092,6 +1092,15 @@ (assert_return (invoke "ϔ") (i32.const 477)) (assert_return (invoke "ẛ") (i32.const 478)) +(module + ;; Test the escapes \r and \' in names. + (func (export "\r") (result i32) (i32.const 0)) + (func (export "\'") (result i32) (i32.const 1)) +) + +(assert_return (invoke "\0d") (i32.const 0)) +(assert_return (invoke "'") (i32.const 1)) + (module ;; Test that we can use indices instead of names to reference imports, ;; exports, functions and parameters. From ef4331240b10fec32c0e7eaa791d690c525caaeb Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Thu, 26 Nov 2026 07:10:30 +0800 Subject: [PATCH 2/2] [test] Add cases for underscores in \u{...} escapes The hex digits of a \u{...} escape follow the hexnum rule, so one underscore between two digits is valid. Export a name with \u{1_F600} and invoke it by its UTF-8 bytes. A leading, trailing, or double underscore is an illegal escape. --- test/core/names.wast | 4 +++- test/core/utf8-invalid-encoding.wast | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/core/names.wast b/test/core/names.wast index 68b2dd1186..be9877976b 100644 --- a/test/core/names.wast +++ b/test/core/names.wast @@ -1093,13 +1093,15 @@ (assert_return (invoke "ẛ") (i32.const 478)) (module - ;; Test the escapes \r and \' in names. + ;; Test the escapes \r, \' and \u{...} with an underscore in names. (func (export "\r") (result i32) (i32.const 0)) (func (export "\'") (result i32) (i32.const 1)) + (func (export "\u{1_F600}") (result i32) (i32.const 2)) ) (assert_return (invoke "\0d") (i32.const 0)) (assert_return (invoke "'") (i32.const 1)) +(assert_return (invoke "\f0\9f\98\80") (i32.const 2)) (module ;; Test that we can use indices instead of names to reference imports, diff --git a/test/core/utf8-invalid-encoding.wast b/test/core/utf8-invalid-encoding.wast index b7d95b7ec8..01e49e7632 100644 --- a/test/core/utf8-invalid-encoding.wast +++ b/test/core/utf8-invalid-encoding.wast @@ -196,3 +196,18 @@ (module quote "(func (export \"\\u{00D800}\"))") "malformed UTF-8 codepoint" ) + +;; An underscore in a \u{...} escape must be between two hex digits. + +(assert_malformed + (module quote "(func (export \"\\u{_1F600}\"))") + "illegal escape" +) +(assert_malformed + (module quote "(func (export \"\\u{1F600_}\"))") + "illegal escape" +) +(assert_malformed + (module quote "(func (export \"\\u{1__F600}\"))") + "illegal escape" +)