fix: don't hang on a tag whose expression ends with a trailing slash#18350
Merged
Conversation
🦋 Changeset detectedLatest commit: a9abde4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
`find_matching_bracket` never advanced `i` when a `/` was the last character of the input, spinning the parser forever. Advance past it so the parse fails with `unexpected_eof` instead of hanging.
a9abde4 to
a2586e3
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a parser hang when a Svelte tag expression ends with a bare trailing /, allowing the compiler to terminate with an unexpected_eof error instead of looping indefinitely.
Changes:
- Advances the bracket scanner past a terminal
/infind_matching_bracket. - Adds a compiler error regression sample for
{let x = a /. - Adds a patch changeset for the Svelte package.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/svelte/src/compiler/phases/1-parse/utils/bracket.js |
Ensures the / branch always makes forward progress at end of input. |
packages/svelte/tests/compiler-errors/samples/declaration-tag-trailing-slash/main.svelte |
Adds the malformed declaration tag regression input. |
packages/svelte/tests/compiler-errors/samples/declaration-tag-trailing-slash/_config.js |
Asserts the expected unexpected_eof compiler error and position. |
.changeset/fix-find-matching-bracket-infinite-loop.md |
Records the patch-level bug fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Merged
hjaber
added a commit
to hjaber/svelte
that referenced
this pull request
Jun 1, 2026
parse_statement_at now drives the boundary with acorn, so an unterminated
declaration tag (e.g. `{let x = a /`) surfaced acorn's generic js_parse_error
instead of the unexpected_eof diagnostic the declaration-tag-trailing-slash
test (sveltejs#18350) relies on. Remap acorn's end-of-input error (err.pos at the end
of the source) back to unexpected_eof; other malformed-at-EOF inputs keep their
more specific acorn message.
Also cast the parsed Statement to acorn.Node for add_comments, resolving the
TS2345 from estree Statement.start being number|undefined.
Rich-Harris
pushed a commit
that referenced
this pull request
Jun 1, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## svelte@5.56.1 ### Patch Changes - fix: error at compile time on duplicate snippet/declaration tag definitions ([#18351](#18351)) - fix: parse declaration tag contents more robustly ([#18353](#18353)) - fix: correctly transform references to earlier declarators in a declaration tag (e.g. `{let a = $state(0), b = $derived(a * 2)}`) ([#18348](#18348)) - fix: avoid spurious `state_referenced_locally` warnings for `$derived` declarations in declaration tags ([#18348](#18348)) - fix: tolerate whitespace before `let`/`const` in declaration tags ([#18348](#18348)) - fix: prevent infinite loop when a tag's expression ends with a trailing `/` at the end of the input ([#18350](#18350)) - fix: more robust parsing of declaration tags with regards to `type` ([#18330](#18330)) - fix: preserve newlines in spread input values when the `type` attribute is applied after `value` ([#18345](#18345)) - fix: update `SvelteURLSearchParams` when setting duplicate keys to the same joined value ([#18336](#18336)) - fix: check references for blockers on server, too ([#18352](#18352)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
huskas-2189
added a commit
to huskas-2189/Bookmark
that referenced
this pull request
Jun 14, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [svelte](https://svelte.dev) ([source](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte)) | [`5.56.0` → `5.56.1`](https://renovatebot.com/diffs/npm/svelte/5.56.0/5.56.1) |  |  | --- ### Release Notes <details> <summary>sveltejs/svelte (svelte)</summary> ### [`v5.56.1`](https://github.com/sveltejs/svelte/blob/HEAD/packages/svelte/CHANGELOG.md#5561) [Compare Source](https://github.com/sveltejs/svelte/compare/svelte@5.56.0...svelte@5.56.1) ##### Patch Changes - fix: error at compile time on duplicate snippet/declaration tag definitions ([#​18351](sveltejs/svelte#18351)) - fix: parse declaration tag contents more robustly ([#​18353](sveltejs/svelte#18353)) - fix: correctly transform references to earlier declarators in a declaration tag (e.g. `{let a = $state(0), b = $derived(a * 2)}`) ([#​18348](sveltejs/svelte#18348)) - fix: avoid spurious `state_referenced_locally` warnings for `$derived` declarations in declaration tags ([#​18348](sveltejs/svelte#18348)) - fix: tolerate whitespace before `let`/`const` in declaration tags ([#​18348](sveltejs/svelte#18348)) - fix: prevent infinite loop when a tag's expression ends with a trailing `/` at the end of the input ([#​18350](sveltejs/svelte#18350)) - fix: more robust parsing of declaration tags with regards to `type` ([#​18330](sveltejs/svelte#18330)) - fix: preserve newlines in spread input values when the `type` attribute is applied after `value` ([#​18345](sveltejs/svelte#18345)) - fix: update `SvelteURLSearchParams` when setting duplicate keys to the same joined value ([#​18336](sveltejs/svelte#18336)) - fix: check references for blockers on server, too ([#​18352](sveltejs/svelte#18352)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled because a matching PR was automerged previously. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTUuMCIsInVwZGF0ZWRJblZlciI6IjQzLjE5NS4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6W119--> Co-authored-by: huskas-2189 <huskas-2189@noreply.codeberg.org> Reviewed-on: https://codeberg.org/huskas-2189/Bookmark/pulls/82
huskas-2189
added a commit
to huskas-2189/Bookmark
that referenced
this pull request
Jun 19, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [svelte](https://svelte.dev) ([source](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte)) | [`5.56.0` → `5.56.1`](https://renovatebot.com/diffs/npm/svelte/5.56.0/5.56.1) |  |  | --- ### Release Notes <details> <summary>sveltejs/svelte (svelte)</summary> ### [`v5.56.1`](https://github.com/sveltejs/svelte/blob/HEAD/packages/svelte/CHANGELOG.md#5561) [Compare Source](https://github.com/sveltejs/svelte/compare/svelte@5.56.0...svelte@5.56.1) ##### Patch Changes - fix: error at compile time on duplicate snippet/declaration tag definitions ([#​18351](sveltejs/svelte#18351)) - fix: parse declaration tag contents more robustly ([#​18353](sveltejs/svelte#18353)) - fix: correctly transform references to earlier declarators in a declaration tag (e.g. `{let a = $state(0), b = $derived(a * 2)}`) ([#​18348](sveltejs/svelte#18348)) - fix: avoid spurious `state_referenced_locally` warnings for `$derived` declarations in declaration tags ([#​18348](sveltejs/svelte#18348)) - fix: tolerate whitespace before `let`/`const` in declaration tags ([#​18348](sveltejs/svelte#18348)) - fix: prevent infinite loop when a tag's expression ends with a trailing `/` at the end of the input ([#​18350](sveltejs/svelte#18350)) - fix: more robust parsing of declaration tags with regards to `type` ([#​18330](sveltejs/svelte#18330)) - fix: preserve newlines in spread input values when the `type` attribute is applied after `value` ([#​18345](sveltejs/svelte#18345)) - fix: update `SvelteURLSearchParams` when setting duplicate keys to the same joined value ([#​18336](sveltejs/svelte#18336)) - fix: check references for blockers on server, too ([#​18352](sveltejs/svelte#18352)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled because a matching PR was automerged previously. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTUuMCIsInVwZGF0ZWRJblZlciI6IjQzLjE5NS4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6W119--> Co-authored-by: huskas-2189 <huskas-2189@noreply.codeberg.org> Reviewed-on: https://codeberg.org/huskas-2189/Bookmark/pulls/82
huskas-2189
added a commit
to huskas-2189/Bookmark
that referenced
this pull request
Jun 19, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [svelte](https://svelte.dev) ([source](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte)) | [`5.56.0` → `5.56.1`](https://renovatebot.com/diffs/npm/svelte/5.56.0/5.56.1) |  |  | --- ### Release Notes <details> <summary>sveltejs/svelte (svelte)</summary> ### [`v5.56.1`](https://github.com/sveltejs/svelte/blob/HEAD/packages/svelte/CHANGELOG.md#5561) [Compare Source](https://github.com/sveltejs/svelte/compare/svelte@5.56.0...svelte@5.56.1) ##### Patch Changes - fix: error at compile time on duplicate snippet/declaration tag definitions ([#​18351](sveltejs/svelte#18351)) - fix: parse declaration tag contents more robustly ([#​18353](sveltejs/svelte#18353)) - fix: correctly transform references to earlier declarators in a declaration tag (e.g. `{let a = $state(0), b = $derived(a * 2)}`) ([#​18348](sveltejs/svelte#18348)) - fix: avoid spurious `state_referenced_locally` warnings for `$derived` declarations in declaration tags ([#​18348](sveltejs/svelte#18348)) - fix: tolerate whitespace before `let`/`const` in declaration tags ([#​18348](sveltejs/svelte#18348)) - fix: prevent infinite loop when a tag's expression ends with a trailing `/` at the end of the input ([#​18350](sveltejs/svelte#18350)) - fix: more robust parsing of declaration tags with regards to `type` ([#​18330](sveltejs/svelte#18330)) - fix: preserve newlines in spread input values when the `type` attribute is applied after `value` ([#​18345](sveltejs/svelte#18345)) - fix: update `SvelteURLSearchParams` when setting duplicate keys to the same joined value ([#​18336](sveltejs/svelte#18336)) - fix: check references for blockers on server, too ([#​18352](sveltejs/svelte#18352)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled because a matching PR was automerged previously. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTUuMCIsInVwZGF0ZWRJblZlciI6IjQzLjE5NS4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6W119--> Co-authored-by: huskas-2189 <huskas-2189@noreply.codeberg.org> Reviewed-on: https://codeberg.org/huskas-2189/Bookmark/pulls/82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #18349
Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.packages/svelte/src, add a changeset (npx changeset).Tests and linting
pnpm testand lint the project withpnpm lint