Skip to content
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

fix(regular_expression): Fix CharacterClass negative codegen #6415

Merged
merged 1 commit into from
Oct 10, 2024
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
7 changes: 3 additions & 4 deletions crates/oxc_regular_expression/src/ast_impl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,11 @@ impl<'a> Display for CharacterClass<'a> {
}

write!(f, "[")?;
if self.negative {
write!(f, "^")?;
}

if !self.body.is_empty() {
if self.negative {
write!(f, "^")?;
}

let sep = match self.kind {
CharacterClassContentsKind::Union => "",
CharacterClassContentsKind::Subtraction => "--",
Expand Down
13 changes: 1 addition & 12 deletions tasks/coverage/snapshots/parser_test262.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@ commit: d62fa93c

parser_test262 Summary:
AST Parsed : 43776/43776 (100.00%)
Positive Passed: 43772/43776 (99.99%)
Positive Passed: 43775/43776 (100.00%)
Negative Passed: 4237/4239 (99.95%)
Expect Syntax Error: tasks/coverage/test262/test/language/import/import-attributes/json-invalid.js
Expect Syntax Error: tasks/coverage/test262/test/language/import/import-attributes/json-named-bindings.js
Expect to Parse: tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T1.js

× Regular Expression content mismatch for `/[^]a/m`: `[]a` == `[]a`
Expect to Parse: tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T2.js

× Regular Expression content mismatch for `/a[^]/`: `a[]` == `a[]`
Expect to Parse: tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T8.js

× Regular Expression content mismatch for `/[^]/`: `[]` == `[]`
Expect to Parse: tasks/coverage/test262/test/built-ins/String/prototype/split/separator-regexp.js

× Regular Expression content mismatch for `/[^]/`: `[]` == `[]`

× Regular Expression content mismatch for `/\cY/`: `\c` == `\c`

× '0'-prefixed octal literals and octal escape sequences are deprecated
Expand Down
14 changes: 2 additions & 12 deletions tasks/coverage/snapshots/semantic_test262.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: d62fa93c

semantic_test262 Summary:
AST Parsed : 43776/43776 (100.00%)
Positive Passed: 43572/43776 (99.53%)
Positive Passed: 43575/43776 (99.54%)
tasks/coverage/test262/test/annexB/language/function-code/if-decl-else-decl-a-func-block-scoping.js
semantic error: Symbol scope ID mismatch for "f":
after transform: SymbolId(3): ScopeId(4294967294)
Expand Down Expand Up @@ -1119,18 +1119,8 @@ semantic error: Symbol scope ID mismatch for "f":
after transform: SymbolId(0): ScopeId(4294967294)
rebuilt : SymbolId(0): ScopeId(4294967294)

tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T1.js
semantic error: Regular Expression content mismatch for `/[^]a/m`: `[]a` == `[]a`

tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T2.js
semantic error: Regular Expression content mismatch for `/a[^]/`: `a[]` == `a[]`

tasks/coverage/test262/test/built-ins/RegExp/S15.10.2.13_A2_T8.js
semantic error: Regular Expression content mismatch for `/[^]/`: `[]` == `[]`

tasks/coverage/test262/test/built-ins/String/prototype/split/separator-regexp.js
semantic error: Regular Expression content mismatch for `/[^]/`: `[]` == `[]`
Regular Expression content mismatch for `/\cY/`: `\c` == `\c`
semantic error: Regular Expression content mismatch for `/\cY/`: `\c` == `\c`

tasks/coverage/test262/test/language/module-code/eval-rqstd-once.js
semantic error: Bindings mismatch:
Expand Down