-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[regression test] /[a-]/v should be a SyntaxError (#29003) #29006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
robobun
wants to merge
6
commits into
main
Choose a base branch
from
farm/a392b8ac/yarr-v-mode-trailing-hyphen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ca369ab
regression test for /[a-]/v (issue #29003)
robobun c49d5c7
test(#29003): trim comments, split guards, todo pending assertions
robobun f2c36f2
rekick CI: restore JSC cache after local surgical rebuild
robobun 73ccda7
rekick CI: pre-existing JSC flake in azure-service-bus (unrelated)
robobun db1cae2
rekick CI: valkey Redis connection flake on every lane (unrelated)
robobun b03f1e6
rekick CI: broadcast-channel-worker-gc JSVMClientData flake (unrelated)
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { expect, test } from "bun:test"; | ||
|
|
||
| // https://github.com/oven-sh/bun/issues/29003 | ||
| // | ||
| // In /v (UnicodeSets) mode, `-` is a ClassSetSyntaxCharacter and is only | ||
| // legal between two ClassSetCharacters as part of a ClassSetRange. A | ||
| // trailing or dangling `-` (e.g. `/[a-]/v`, `/[\d-]/v`) must be rejected | ||
| // as a SyntaxError. | ||
|
|
||
| test("issue #29003 - /[a-]/v throws SyntaxError", () => { | ||
| expect(() => new RegExp("[a-]", "v")).toThrow(SyntaxError); | ||
| // Regex literal form too — the parser path is the same but the expression | ||
| // gets routed through a different call site in the transpiler. | ||
| expect(() => eval("/[a-]/v")).toThrow(SyntaxError); | ||
| }); | ||
|
|
||
| test("issue #29003 - other dangling hyphen forms in /v mode also throw", () => { | ||
| // Reported siblings that already errored — kept here to lock them in. | ||
| expect(() => new RegExp("[-a]", "v")).toThrow(SyntaxError); | ||
| expect(() => new RegExp("[-]", "v")).toThrow(SyntaxError); | ||
|
|
||
| // Newly-rejected forms that share the same root cause: a pending `-` | ||
| // with no right-hand ClassSetCharacter when the class/operator/nested | ||
| // class boundary is reached. | ||
| expect(() => new RegExp("[\\d-]", "v")).toThrow(SyntaxError); | ||
| expect(() => new RegExp("[\\w-]", "v")).toThrow(SyntaxError); | ||
| expect(() => new RegExp("[a-z\\d-]", "v")).toThrow(SyntaxError); | ||
| }); | ||
|
Check failure on line 28 in test/regression/issue/29003.test.ts
|
||
robobun marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| test("issue #29003 - valid /v patterns still parse", () => { | ||
| // Sanity: the fix must not regress patterns that were legal before. | ||
| expect(new RegExp("[a-z]", "v").test("m")).toBe(true); | ||
| expect(new RegExp("[a\\-]", "v").test("-")).toBe(true); | ||
| expect(new RegExp("[\\-a]", "v").test("-")).toBe(true); | ||
| expect(new RegExp("[a--b]", "v").test("a")).toBe(true); | ||
| expect(new RegExp("[a&&b]", "v").test("a")).toBe(false); | ||
| expect(new RegExp("[\\w--\\d]", "v").test("a")).toBe(true); | ||
| }); | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.