Files
Shanon Jackson 275c2f8302 fix(lexer): regex vs division when ASI ends the previous statement (#25355)
`prev_is_regex` walks back one token to decide whether `/` opens a
regex. When a newline forces ASI but the previous token still looks
expression-final, it answered division. The JSX `<` decision goes
through the same function, so TSX was wrong in the same places.

```ts
let x: T
/re/.exec(s)      // was lexed as division

let x
/re/.test(s)

import y from 'm'
/re/.exec(s)

break outer
/re/.test(x)

let x: 1
/re/.exec(s)

let x!: T
/re/.exec(s)
```

Also `type A = T`, `declare function f(): T`, `function f(): void {}`,
template literal types, and `continue label`.

Free on the hot path: ASI needs a newline before the `/`, so the
backward walks sit behind an `lt_in_range` gate that straight-line `a /
b` never passes. No measurable change over the fixture corpus.

18 tests added.
2026-08-07 14:04:14 +01:00
..

Oxc Lexer

A spec compliant standalone lexer for JS/JSX/TS.

Overview

  • Test262 compliant.
  • TS/JSX Working
  • UTF-8 validation costs 0.15CPB (Cycles per byte), optional parameter.
  • SIMD in x86_64 AVX2, Scalar for every other platform currently (in progress).
  • Regex vs Division cases should be handled even in pathological cases.