Skip to content
Open
Changes from 1 commit
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
38 changes: 38 additions & 0 deletions test/regression/issue/29003.test.ts
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

View check run for this annotation

Claude / Claude Code Review

Tests will fail CI before WebKit fix lands; regression guards structurally ineffective

Tests at lines 10–15 and 25–27 assert SyntaxError for patterns Bun currently accepts (the WebKit fix has not yet been applied), so they will fail CI with both `bun bd test` and `USE_SYSTEM_BUN=1 bun test`, violating CLAUDE.md's requirement that tests pass with `bun bd test`. Additionally, test 2 (lines 17–28) mixes already-passing regression guards (lines 19–20) with the not-yet-fixed assertions (lines 25–27) in a single `test()` call, which makes the regression guards structurally ineffective r

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);
});
Loading