Skip to content

Commit

Permalink
fix(regular_expression): Fix CharacterClass negative codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
leaysgur committed Oct 10, 2024
1 parent a1a2721 commit 108e6f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
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

0 comments on commit 108e6f0

Please sign in to comment.