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
Handle strings when skipping function bodies
Explicitly parse strings in the logic for mostly skipping function bodies in the first parser phase. This avoids parentheses inside strings causing the parser to skip too much or too little of the input.
  • Loading branch information
tlively committed Apr 16, 2026
commit 1ff3225c22b9e484f81d9da4eba30b9dd208b35b
5 changes: 5 additions & 0 deletions src/parser/context-decls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 7 additions & 0 deletions test/lit/wat-kitchen-sink.wast
Original file line number Diff line number Diff line change
Expand Up @@ -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 ")")
)
)
)
Loading