mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
275c2f8302
`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.
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.