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
1 change: 0 additions & 1 deletion scripts/test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ def get_tests(test_dir, extensions=[], recursive=False):
'linking.wast', # Missing function type validation on instantiation
'proposals/threads/memory.wast', # Missing memory type validation on instantiation
'annotations.wast', # String annotations IDs should be allowed
'id.wast', # Empty IDs should be disallowed
'instance.wast', # Requires support for table default elements
'table64.wast', # Requires validations for table size
'tag.wast', # Non-empty tag results allowed by stack switching
Expand Down
7 changes: 7 additions & 0 deletions src/parser/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,10 +866,17 @@ std::optional<LexIdResult> ident(std::string_view in) {
if (!ctx.takePrefix("$"sv)) {
return {};
}
// Quoted identifier e.g. $"foo"
if (auto s = str(ctx.next())) {
if (!String::isUTF8(s->getStr())) {
return {};
}

// empty names, including $"" are not allowed.
if (s->span == "\"\"") {
return {};
}

ctx.isStr = true;
ctx.str = s->str;
ctx.take(*s);
Expand Down
2 changes: 1 addition & 1 deletion test/gtest/wat-lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ TEST(LexerTest, LexIdent) {
EXPECT_FALSE(Lexer("$"sv).takeID());

// String IDs
EXPECT_EQ(Lexer("$\"\""sv).takeID(), wasm::Name(""sv));
EXPECT_EQ(Lexer("$\"\""sv).takeID(), std::nullopt);
EXPECT_EQ(Lexer("$\"hello\""sv).takeID(), wasm::Name("hello"sv));
// _$_£_€_𐍈_
EXPECT_EQ(Lexer("$\"_\\u{24}_\\u{00a3}_\\u{20AC}_\\u{10348}_\""sv).takeID(),
Expand Down
4 changes: 2 additions & 2 deletions test/lit/basic/imported-params.wast
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(module
(import "" "" (func (param i32 i64) (param $x i32) (param $y i64) (param f32 f64)))
(import "" "" (func (param $x i32) (param f32 f64) (param $y i64)))
(import "" "" (func (param $"" i32)))
(import "" "" (func (param $"\tfoo" i32)))
)
;; CHECK: (type $0 (func (param i32 i64 i32 i64 f32 f64)))

Expand All @@ -19,4 +19,4 @@

;; CHECK: (import "" "" (func $fimport$1 (param $x i32) (param f32 f64) (param $y i64)))

;; CHECK: (import "" "" (func $fimport$2 (param $"" i32)))
;; CHECK: (import "" "" (func $fimport$2 (param $"\tfoo" i32)))
Loading