Commit Graph

53 Commits

Author SHA1 Message Date
camc314 dc09a3aa9d fix(parser): avoid panic on escaped string export names (#26146)
## Summary

Fix a parser panic when a string-named export decodes to a literal `\u` sequence.

Lone-surrogate validation now uses the metadata captured by the lexer instead of rescanning decoded string contents. This also prevents false diagnostics for names such as `"\\uD800"`.

## Before:

```

thread 'main' (10990283) panicked at crates/oxc_ast/src/ast_impl/literal.rs:89:42:
end byte index 4 is out of bounds for string of length 0
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
   4: <core::ops::range::RangeTo<usize> as core::slice::index::SliceIndex<str>>::index
   5: <str as core::ops::index::Index<core::ops::range::RangeTo<usize>>>::index
   6: <oxc_ast::ast::literal::StringLiteral>::is_string_well_formed_unicode
   7: <oxc_parser::ParserImpl<oxc_parser::config::NoTokensParserConfig>>::parse_module_export_name
```
2026-08-28 13:37:48 +00:00
Boshen fca2e0cfed fix(parser): reject initialized lexical declarations in for-in (#25700)
Rejects initialized `let` and `const` declarations in `for...in` during parsing while preserving Annex B's non-strict `var` form.

Adds misc coverage for valid and invalid initializer forms.

Verified with `just ready` and parser conformance.

Closes #25149.

AI-assisted.
2026-08-15 06:58:08 +00:00
Boshen cdf1846af2 fix(semantic): allow legacy escapes in JSX attributes (#25576)
Quoted JSX attribute values do not use ECMAScript escape sequences. Skip strict-mode legacy escape validation for JSX attributes and cover the behavior in misc conformance.

AI-assisted by Codex.
2026-08-13 07:06:42 +00:00
Cameron 12937b3201 fix(parser): reject comma expressions in class fields (#25385)
## Summary

- parse ordinary class field initializers as `AssignmentExpression`
- reject unparenthesized comma expressions while preserving
parenthesized sequence expressions
- add paired misc conformance fixtures and update the generated
snapshots

## Root cause

Ordinary class field initializers used `parse_expr`, which accepts a
top-level comma and constructs a sequence expression. The ECMAScript
`Initializer` grammar requires an `AssignmentExpression`, so the
unparenthesized comma must remain for the class-element terminator check
to reject.
2026-08-08 10:59:23 +00:00
camc314 9e93ba6908 fix(parser): reset auto-accessor initializer context (#25384)
## Summary

- Align auto-accessor initializer parsing with class-field initializer grammar.
- Add regressions for `in` in a `for` initializer and disallowed inherited `await`/`yield` contexts.

## Root cause

The auto-accessor path only enabled `new.target`. It therefore inherited outer `~In`, `Await`, and `Yield` grammar contexts: `a in b` could not parse in a `for` initializer, while `await` and `yield` could incorrectly parse from enclosing async/generator functions. The fix applies the same `In | NewTarget` addition and `Yield | Await` removal already used for class fields, while retaining AssignmentExpression parsing.

## References

- [ECMAScript `FieldDefinition` grammar](https://tc39.es/ecma262/#prod-FieldDefinition)
- [ECMAScript `Initializer` grammar](https://tc39.es/ecma262/#prod-Initializer)
- [TC39 decorators proposal: class auto-accessors](https://github.com/tc39/proposal-decorators#introduction)
2026-08-07 23:03:24 +00:00
camc314 5c5cdcd522 feat(ast)!: narrow TSInterfaceHeritage::expression to TSTypeName (#24360)
## Summary

Narrow `TSInterfaceHeritage` from a general JavaScript `Expression` to `TSTypeName`.

```rust
pub struct TSInterfaceHeritage<'a> {
    pub type_name: TSTypeName<'a>,
    pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
}
```

## Breaking Change

The Rust AST field changes from:

```rust
expression: Expression<'a>
```

to:

```rust
type_name: TSTypeName<'a>
```

## Why?

The current AST can represent shapes such as:

```ts
interface A extends foo() {}
interface A extends A + B {}
interface A extends new Foo() {}
interface A extends true {}
```

Which is an overly wide type since all of the above variants are invalid.

This PR tightens up the AST, making these invalid variants irrepresentable.

## How to migrate?

This should be a trivial migration:
1. instead of accessing `expression` on `TSInterfaceHeritage`, now access `type_name`
2. change any pattern matching on the `type_name` field to use `TypeName` (this is a smaller subset so should allow deleting code!)

closes https://github.com/oxc-project/backlog/issues/215
2026-08-07 06:00:42 +00:00
Boshen 582805df03 fix(parser): parse unary conditional after satisfies (#24807)
Fixes #24804.

Recognize `!` as a type-start token so `?` after `satisfies` remains the conditional-expression operator instead of being consumed as a JSDoc nullable type.

Validated with `just ready`.

AI-assisted.
2026-07-22 13:22:14 +00:00
camc314 47ddedf011 fix(semantic): allow arguments in ambient declarations (#24758)
## Summary

- allow `eval` and `arguments` as direct bindings in ambient declarations
- continue reporting strict-mode errors for destructured ambient bindings
- add focused coverage for declared functions, classes, object patterns, and array patterns

## Why

The semantic checker previously identified allowed bindings by walking to a `TSDeclareFunction`. That missed other ambient declarations, including declared class constructors and methods, and produced diagnostics for TypeScript cases that require no runtime code generation.

The check now uses the existing ambient-context state and rejects only destructuring binding shapes.
2026-07-21 12:43:21 +00:00
camc314 129b759131 feat(parser): improve diagnostics for unparenthesized LHS on exponential expr (#24569)
## Summary

- Report operator-specific diagnostics when unary and `await` expressions are used as exponentiation left operands.
- Reject unparenthesized TypeScript type assertions in the same position while preserving explicitly parenthesized forms.
- Add regression fixtures and update the affected conformance snapshots.
2026-07-15 18:38:30 +00:00
camc314 1ebdce31b6 fix(semantic): allow reserved keywords in ambient declaration types (#24325)
Recognize identifiers nested within `declare` variable declarations and declared class properties as being in an ambient context.

This prevents valid TypeScript from incorrectly producing reserved-keyword diagnostics.

### Examples

Function types inside ambient variable declarations are now accepted:

```ts
declare let f: (package: number) => interface;
```

Type references inside declared class properties are also accepted:

```ts
class C {
  declare field: package;
}
```
Previously, package and interface were incorrectly reported as reserved keywords.
2026-07-09 10:40:33 +00:00
camc314 e8b50ee716 fix(transformer): clean up semantics for stripped TypeScript syntax (#24180)
## Summary

Keep transformer semantic data in sync when TypeScript-only syntax is removed.

This change:

- removes resolved and unresolved references belonging only to stripped TypeScript syntax
- removes bindings for erased type-only and unused imports
- preserves runtime bindings when a type import is merged with a value declaration
- promotes the surviving declaration’s symbol flags, span, and redeclaration metadata
- adds coverage for type imports merged with runtime declarations
- refreshes semantic and transformer conformance snapshots

## Motivation

We are preparing to change the AST shape, including adding and rearranging scopes.

Currently, transformer semantic snapshots contain thousands of lines of mismatches caused by stale bindings and references from TypeScript syntax that has already been removed from the AST. That creates a large amount of unrelated snapshot noise.

With that noise present, snapshot changes caused by the upcoming AST work would be difficult to review: a real scope or semantic regression could easily be hidden among mechanical churn.

This PR fixes the underlying semantic inconsistencies first, giving us a much cleaner baseline for reviewing future AST and scope changes. It is not intended to change emitted JavaScript.
2026-07-06 08:11:46 +00:00
camc314 1d3af58c4a feat(parser): add TS2398 parameter property diagnostic (#23216)
## Summary

- Report TS2398 when a TypeScript constructor parameter property is named `constructor`.
- Add coverage for the upstream TypeScript fixture plus dedicated misc pass/fail cases for ordinary `constructor` parameters versus invalid parameter properties.

```
  × TS(2398): 'constructor' cannot be used as a parameter property name.
   ╭─[misc/fail/oxc-ts-2398.ts:2:31]
 1 │ class A {constructor(public constructor){}}
 2 │ class B {constructor(readonly constructor){}}
   ·                               ───────────
   ╰────
```
2026-06-11 08:39:25 +00:00
Boshen 17e7cf3ce4 fix(parser): disallow unerasable as/satisfies assertions (#22986)
Port of [microsoft/typescript-go#4192](https://github.com/microsoft/typescript-go/pull/4192), which fixes [microsoft/TypeScript#63527](https://github.com/microsoft/TypeScript/issues/63527).

## Problem

`as`/`satisfies` are supposed to be erasable without changing runtime semantics. But for an expression of the form `a ## b as T $$ c`, where `##` has *lower* precedence than `$$`, erasing the assertion silently changes the parse:

```ts
const x = 1 + 1 as number * 2;
```

This parses as `((1 + 1) as number) * 2` (= `4`), but textually erasing `as number` yields `1 + 1 * 2` (= `3`). TypeScript now rejects such constructs as a syntax error, forcing explicit parentheses.

## Change

In `parse_binary_expression_rest`, after parsing an `as`/`satisfies` type, stop parsing if the following operator binds tighter than the operator that produced the running left-hand operand. This leaves the higher-precedence operator dangling and surfaces as a parse error.

A chained `a as T as U` keeps referring back to the original operator's precedence (the tracked precedence is intentionally not updated while consuming `as`/`satisfies`), so `1 + 1 as any as number * 2` is rejected too.

## Behavior

| Expression | Result |
| --- | --- |
| `1 as number * 2` | ok |
| `1 * 1 as number + 2` | ok (`+` does not bind tighter than `*`) |
| `1 + 1 as number * 2` | **error** |
| `1 + 1 as any as number * 2` | **error** |
| `1 >> 1 as number + 2` | **error** |
| `(1 + 1 as number) * 2` | ok |

`satisfies` behaves identically to `as`.

## Tests

Added `misc` coverage fixtures mirroring the upstream test matrix: `pass/ts-erasable-as-satisfies.ts` for the erasable cases and `fail/ts-unerasable-{as,as-chained,satisfies}.ts` for the rejected ones. Full conformance (test262 / babel / typescript) shows zero regressions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-06-05 13:10:42 +00:00
Boshen b284045af2 fix(parser): switch to module goal eagerly on export (#22684)
## Summary

In unambiguous (`.js` auto-detect) sources, `export var x = await + 1;` reported a spurious `Duplicated export 'x'` error. The parser first parsed the statement with `await` as an identifier, then re-parsed it under `Context::Await` to patch the AST — but the second pass re-invoked `visit_export_named_declaration`, recording the binding `x` a second time in the module record.

`export` is unambiguously module syntax per ECMA-262 §16.2.3 (`ExportDeclaration` is only a `ModuleItem`, never a Script production). So commit to the Module goal — enable `Context::Await` — as soon as the next top-level token is `Kind::Export`. The statement then parses correctly on the first attempt; no reparse and no duplicate record.

`Kind::Import` is intentionally **not** eager-switched. TypeScript's `import name = ns.path` is a script-compatible namespace alias (see `topLevelAwait.2.ts`), so treating `import` as a module starter would break that case.

The only TS snapshot churn is +16 lines of additional error messages for already-failing tests (`topLevelAwaitErrors.5.ts`, `topLevelAwaitErrors.6.ts` — `export ... await`). Summary counts unchanged.

Closes #22520
Fixes #22158
2026-05-23 06:00:04 +00:00
camc314 9fa2122cef fix(parser): parse array computed class keys (#22159)
Fixes parser recovery for class computed property names whose expression starts with an array literal, such as `class C { [[]]() {} }`.

The TypeScript index-signature lookahead previously treated a nested `[` after the opening computed-name bracket as an unambiguous index signature. That caused valid class computed keys containing array literals to be parsed through the wrong branch and rejected.

This changes the lookahead so only `...` remains an early unambiguous index-signature signal, allowing nested arrays and other assignment expressions to parse as computed property names.

fixes: #22157
2026-05-05 20:46:22 +00:00
camc314 78c264a783 fix(parser): fix conditional expressions with arrow-function alternates in TS (#20356)
fixes https://github.com/rolldown/rolldown/issues/8676
2026-03-14 07:18:30 +00:00
Boshen 993fd2b799 feat(parser): parse unambiguous await with better error messages (#18480)
## Summary

- Add `is_unambiguous_await()` to detect when `await x` is clearly an await expression
- Unambiguous top-level await upgrades file to ESM (like Babel's `sawUnambiguousESM`)
- Add `function_depth` tracking so await inside non-async functions errors even in ESM
- Treat `await of` and `await using` as ambiguous (for-await-of and await using declarations)
- Better error messages: "await is only allowed within async functions" instead of confusing "Expected semicolon" errors

Closes #15541
Closes #18457

🤖 Generated with [Claude Code](https://claude.ai/code)
2026-01-24 11:28:31 +00:00
Boshen 5813af9794 fix(coverage): use resolved source type for idempotency test second parse (#18464)
## Summary

- In idempotency tests, the second parse now uses the source type derived from `program.source_type` after the first parse, not the original input source type
- This ensures consistent parsing when the source type is resolved (e.g., from unambiguous to module/script)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-01-24 03:18:06 +00:00
overlookmotel 22b4d39bd5 test(semantic): add test cases for function redeclaration check (#18288)
Follow-on after #18231. Add test cases to make sure function redeclaration check works correctly in script, module, and CommonJS files.
2026-01-20 14:09:09 +00:00
Sysix 37482eba73 fix(parser): respect optional TSNamedTupleMember for ts error 1266 &1257 (#18178)
> This PR fixes TypeScript parser errors 1266 and 1257 by properly handling the `optional` field of `TSNamedTupleMember` when validating tuple element ordering constraints.

Introduced in #18146 and #18145
2026-01-18 11:35:35 +00:00
Boshen 91126a01a4 fix(parser): reparse all statements with await identifier in unambiguous mode (#18163)
## Summary

- Fix parsing of `await (...)` and other cases where `await` followed by
certain tokens was parsed as an identifier instead of an await
expression in unambiguous mode
- Commit 92e27b4 only handled `await /regex/` but missed other cases

## Changes

- Add `encountered_await_identifier` flag to `ParserState` to track when
await is parsed as identifier
- Set flag in `parse_identifier_reference` when parsing "await" as
identifier in non-await context
- Modify statement parsing to track checkpoints only for statements that
actually used await as identifier
- Once ESM detected, enable await context for remaining statements

## Test plan

- Added test cases in `tasks/coverage/misc/pass/`:
- `unambiguous-await-call.js` - Tests `await (async function () { })();`
- `unambiguous-await-in-declaration.js` - Tests `const x = await (async
function () { })();`
- All parser tests pass
- All conformance tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 11:18:37 +08:00
Boshen 92e27b4e01 feat(parser): reparse await expressions in unambiguous mode when ESM detected (#18139)
## Summary

- Implements TypeScript-compatible await expression reparsing for unambiguous mode
- When `sourceType` is `unambiguous`, `await / 0 /u; export {}` now correctly parses as `await /0/u` (await expression with regex)
- Follows TypeScript's two-pass approach: initially parse `await` as identifier, then reparse with await context if ESM is detected

## Test plan

- Added `tasks/coverage/misc/pass/unambiguous-await-regex.js` test case
- Moved `tasks/coverage/misc/fail/babel-16776-s.js` to pass (now parses as division in script mode)
- All parser tests pass
- Conformance tests show improvements in parser_babel and semantic_babel

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-01-17 15:27:42 +00:00
Boshen 66b8c022ab feat(parser): implement unambiguous module parsing for JS/TS files (#18124)
## Summary

- Implements speculative/unambiguous parsing for `.js`, `.jsx`, `.ts`, and `.tsx` files
- Instead of assuming module or script upfront, parses with `ModuleKind::Unambiguous` and upgrades to module mode when ESM syntax is detected
- ESM indicators: `import`, `export`, `import.meta` (NOT top-level await alone)
- Defers top-level await errors until module type is resolved
- Vue loader upgrades unambiguous scripts to module mode
- Updates linter tests to use explicit ESM extensions (`.mjs`/`.mts`) where needed

## Test plan

- [x] All parser tests pass
- [x] All linter tests pass
- [x] All semantic tests pass
- [x] Coverage conformance tests updated

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-01-17 13:40:28 +00:00
Boshen fb181ccdff fix(semantic): error on using at top level in scripts (#18090)
## Summary

- Add check to error on `using` declarations at the top level of scripts
- `using` declarations require block scope semantics and are not allowed
at the top level of scripts

`using` declarations are allowed:
- At the top level of ES modules
- At the top level of CommonJS modules (files are wrapped in a function)
- Inside any block scope in scripts

But NOT at the top level of scripts.

Closes #11862

## Test plan

- [x] Added test case
`tasks/coverage/misc/fail/script-top-level-using.js` for invalid usage
- [x] Added test case
`tasks/coverage/misc/pass/script-using-in-block.js` for valid usage in
block
- [x] All existing tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 12:18:26 +08:00
Boshen 08dad63678 feat(span): add sourceType: 'commonjs' support (#18089)
## Summary

- Add `ModuleKind::CommonJS` variant to support CommonJS module type in the parser
- Enable top-level `return` statements (CommonJS files are wrapped in a function)
- Enable top-level `new.target` (allowed in CommonJS function wrapper)
- Add proper errors for `import`/`export` statements in CommonJS
- Add proper errors for `import.meta` in CommonJS

The CommonJS source type can be set via:
- `SourceType::with_commonjs(true)` method
- Babel's `sourceType: "commonjs"` option

Closes #16200

## Test plan

- [x] Added test cases in `tasks/coverage/misc/pass/` for valid CommonJS features
- [x] Added test cases in `tasks/coverage/misc/fail/` for invalid CommonJS usage
- [x] Enabled Babel conformance tests for `sourceType: "commonjs"`
- [x] All existing tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-01-16 16:08:27 +00:00
sapphi-red cb515fac28 feat(parser): improve error message for yield as identifier usage (#16950)
Improved error message for `yield` as identifier usage.

**Before**
```
  × Cannot use `yield` as an identifier in a generator context
    ╭─[test262/test/language/expressions/generators/yield-weak-binding.js:17:33]
 16 │
 17 │ var g = function*() { yield 3 + yield 4; };
    ·                                 ─────
    ╰────
```
**After**
```
  × Cannot use `yield` as an identifier in a generator context
    ╭─[test262/test/language/expressions/generators/yield-weak-binding.js:17:33]
 16 │
 17 │ var g = function*() { yield 3 + yield 4; };
    ·                                 ─────
    ╰────
  help: Wrap this in parentheses if you want to use a `yield` expression here
```
2025-12-16 11:30:44 +00:00
Copilot cb88414309 fix(parser): consume semicolon after let.x and let?.x (#16857)
`let.x;` and `let?.x;` were parsed as two statements
(ExpressionStatement + EmptyStatement) instead of one. This caused
codegen idempotency failures.

**Root cause**: In `parse_let()`, the branch handling member access and
optional chaining on `let` directly constructed the statement without
consuming the semicolon:

```rust
} else if matches!(peeked, Kind::Dot | Kind::QuestionDot | Kind::LParen) {
    let expr = self.parse_expr();
    self.ast.statement_expression(self.end_span(span), expr)  // semicolon left unparsed
```

**Fix**: Call `parse_expression_statement()` to apply ASI:

```rust
} else if matches!(peeked, Kind::Dot | Kind::QuestionDot | Kind::LParen) {
    let expr = self.parse_expr();
    self.parse_expression_statement(span, expr)  // consumes semicolon
```

This matches the pattern used in other branches of the same function.

<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>Parser: `let.x;` or `let?.x;` is parsed as 2
statements</issue_title>
> <issue_description>Fixing oxc-project/oxc#16839 surfaced another
obscure bug.
> 
> ```js
> let.x;
> let?.x;
> ```
> 
> These are each parsed as 2 statements - 1 x `ExpressionStatement` + 1
x `EmptyStatement`.
> 
>
[Playground](https://playground.oxc.rs/#eNptU8Fu2zAM/Reds6ErMKDITkO7AAO6tVuH9bILLdOuUlnSSDpJYeTfS7mWkkNPth5F8vHxaTLWrI1H+Xj48i+YlYlmPRkaQ/54F8SsO/CMK9NFGkAEqSJCEDjDFXEcPQi2N2g9EIiLgWtw/+QEOYHFCg0Qen862jgkQj6lsI1Jw0JjPrwMTfTlZLt+uXZcmQTEmdhk8CAYWPvqVHbLOhB4H/e/UUYKd6Owa3EzBpuplVK5J9IO74E0t6Bz3t+r70HIaUVbA4xKW5z9RhRpQZVDFmvmoP9nWk1mZPwDzWkogebRtfJk1pcrg6G9625d0CmN75Ru0m6yxK8utJvLEv0ao5x02vLh4R34fz7dU0zaywB/CIgttlpTF+WUXn8dhwFyzHtFdQ5Xh9VZ9mV+je/hJWvXENhnlAddmqaXywWFAd+YL/1js0UrjwRJaxRRc6OZ61dRIZtRGSKdpala1UdveglQj+o7g3x58emzFlAFb7DTnE2kaw/MG4e+rQvBQ0JyAwYBr86Lary6GI0OTir6AwVaEBVh2dr7jp0MK9mku0cKoJ4rVG1sscf5cYS842rHLbdRX9KiZghR5loF8diXu3OV4vNslvIIdPKYbnGHtegzYvqpKhfvzKnqx+g36s2csUNqIp9p6ULeQQ7Vv6PC7SxfhuvfMeNZZmAxx1f2XG/6)
> 
> Once fixed, this idempotency test failure for `oxc_codegen` should be
resolved:
> 
>
https://github.com/oxc-project/oxc/blob/c7c05ba2612ca84978214cff7c1e9e836a5b319b/tasks/coverage/snapshots/codegen_misc.snap#L4</issue_description>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> </comments>
> 


</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes oxc-project/oxc#16856

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: overlookmotel <557937+overlookmotel@users.noreply.github.com>
Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-12-14 21:14:44 +00:00
Copilot d3208dc969 fix(parser): parse let?.x (#16840)
Fixes #16839.

Make parser parse `let?.x` successfully.

There's a failure in codegen idempotency tests, but that's an unrelated
and pre-existing bug, so am leaving that to another PR.

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2025-12-14 19:26:57 +00:00
camc314 1199cee3ae fix(parser): reject invalid modifiers on parameter properties with binding patterns (#16083)
Fixes #16077
2025-11-25 09:43:09 +00:00
sapphi-red 2191ae9f8d fix(semantic): allow reserved keywords in typescript ambient contexts (#15495)
Reserved keywords are allowed as an identifier in ambient contexts.
```ts
declare const private: number
```
This is allowed.
2025-11-18 08:11:22 +00:00
sapphi-red d60ca818e7 fix(parser): reject import something 'source' (#15746)
```js
import something 'source'
```
was not rejected but this should be rejected.
https://tc39.es/ecma262/2025/multipage/ecmascript-language-scripts-and-modules.html#prod-ImportDeclaration
2025-11-17 02:58:51 +00:00
camc314 8951953008 feat(parser): improve diagnostic messages for merge conflicts (#15443)
Adds detection and improved error messages for version control merge conflicts encountered in the parser.

This is based upon rustc's implementation.
2025-11-08 06:53:50 +00:00
sapphi-red c28807b32c fix(parser): reject async await => {} in scripts (#15222)
`async await => {}` was rejected in modules but should be rejected in scripts as well.
2025-11-02 12:08:56 +00:00
Boshen dc9645f98f fix(semantic): allow super in object literal method inside a class (#13463)
fixes #13284
2025-08-31 21:06:40 +00:00
overlookmotel fd3233cf95 fix(semantic): flag super in function inside ObjectExpression (#13325)
Fix #13323.

Make semantic raise errors for the following illegal `super` uses:

```js
o = {
  foo: function() {
    super.foo;
  },

  bar() {
    return function() {
      super.bar;
    };
  },

  [ function() { super.qux; } ]() {},

  get [ function() { super.bing; } ]() {},

  set [ function() { super.bong; } ](v) {},
};
```
2025-08-29 13:10:08 +00:00
Boshen 8a43068a27 fix(semantic): allow super in object method in js but not in ts (#13318)
closes #13284

Either TypeScript implemented the spec incorrectly or made it more
strict.

```js
class C {
  foo() {
    return {
      bar() {
        super.bar(); // syntax error in ts but not in js
      },
    };
  }
}
```
2025-08-27 02:20:08 +00:00
Li Wei 724837e75f fix(semantic): label redeclaration check for crossing boundary on arrow function (#12679) (#12948)
In the previous implementation, check label cross boundary on function
or static block, but ignore arrow function

fixes #12679
2025-08-10 15:17:07 +08:00
camc314 ce5876d5b5 fix(parser): validate inner expression of type assertions in assignment targets (#12614)
fixes #12612
2025-08-01 04:42:56 +00:00
camc314 e82f758ff9 fix(semantic): allow arguments/eval as argument name inside TSFunctionType (#12288) 2025-07-16 01:45:12 +00:00
Boshen 4e40089741 fix(parser): parse TSTypePredicate correctly (#11666)
fixses #11659
2025-06-13 10:16:19 +00:00
Boshen eb55d839c1 fix(parser): parse using() correctly (#11664)
closes #11658
2025-06-13 07:44:52 +00:00
Boshen e9a8832ce6 refactor(parser): rewrite decorator parsing (#11604)
fixes #11593

Parse decorators and pass them around explicitly instead of using a state to store them.
2025-06-11 11:11:58 +00:00
camchenry 551cd2a790 fix(parser): fix parsing of import source and import defer (#11537)
- closes https://github.com/oxc-project/oxc/issues/11532
2025-06-07 03:57:33 +00:00
Cam McHenry 8d9919fc49 fix(parser): parse import type from ... correctly in JS files (#11506)
- fixes https://github.com/oxc-project/oxc/issues/11505

I forgot to add a `self.is_ts` check for parsing `import type from ...`.
In JS files, this is just a normal default import.

Co-authored-by: Cameron McHenry <camchenry@lovelace.localdomain>
2025-06-06 15:26:35 +08:00
Boshen be3bd8ce22 fix(parser): fix panic while parsing async await => {} in module (#11493)
fixes #11487
2025-06-05 05:01:20 +00:00
camc314 2b02d84565 fix(parser): allow for(using using stmts (#10985)
fixes #10981
2025-05-14 04:57:57 +00:00
Boshen 7664bd0018 fix(parser): fix using asi (#10504)
fixes #10503

```ts
using
foo = bar()

await using
foo = bar()
```

should be parsed as

```ts
using;
foo = bar()

await using;
foo = bar()
```

not

```ts
using foo = bar()

await using foo = bar()
```
2025-04-19 05:28:30 +00:00
Dunqing bc54d1fabd fix(semantic): redeclare variable with function declaration inside the function should not throw error (#10160)
close: #10159
2025-04-01 13:05:30 +00:00
Dunqing a88eb5638e fix(parser): parsing errors occur when type parameters are followed by as or satisfies (#9553)
close: #9541
2025-03-05 06:09:39 +00:00
Boshen bde412692d feat(parser): parse a ? b ? (c = 0) : d => 1 : (e = 2) : f => 3 (#9229)
closes #9215
2025-02-19 13:31:14 +00:00