diff --git a/src/parser/context-decls.cpp b/src/parser/context-decls.cpp index 73327bd1640..3afa960ee5a 100644 --- a/src/parser/context-decls.cpp +++ b/src/parser/context-decls.cpp @@ -329,6 +329,11 @@ bool ParseDeclsCtx::skipFunctionBody() { } continue; } + // Avoid confusion due to parens inside strings by skipping strings as a + // unit. + if (in.takeString()) { + continue; + } in.take(1); in.advance(); } diff --git a/test/lit/wat-kitchen-sink.wast b/test/lit/wat-kitchen-sink.wast index 9e3c6171f4b..aeaf68182a6 100644 --- a/test/lit/wat-kitchen-sink.wast +++ b/test/lit/wat-kitchen-sink.wast @@ -5273,4 +5273,11 @@ ) ) ) + + (func $paren-in-string + ;; We should not be tripped up by an extra close parenthesis inside a string. + (drop + (string.const ")") + ) + ) )