Commit graph

537 commits

Author SHA1 Message Date
Boshen
e75e0f1465 chore: update test262 / babel / typescript submodules (#5369)
closes #5215
2024-08-31 12:28:25 +00:00
overlookmotel
8a178075b7 fix(parser): treat JSX element tags starting with _ or $ as IdentifierReferences (#5343)
#5223 added a new variant `JSXElementName::IdentifierReference` for JSX identifiers which are treated as references (e.g. `<Foo>`) as opposed to `JSXElementName::Identifier` which is for lowercase (e.g. `<div>`).

But we were incorrectly categorizing identifiers beginning with `_` or `$` - these should also be treated as references.

(as discussed in https://github.com/oxc-project/oxc/pull/5339#issuecomment-2321037779)
2024-08-30 14:47:06 +00:00
overlookmotel
0de844d23c refactor(transformer): remove unnecessary code from JSX transform (#5339)
Follow-on after #5223.

JSX identifiers which start with a capital letter are now `JSXElementName::IdentifierReference`s, so no need to check for capitalized `JSXElementName::Identifier`s.
2024-08-30 12:17:08 +00:00
Dunqing
32f730085c feat(ast)!: add JSXElementName::IdentifierReference and JSXMemberExpressionObject::IdentifierReference (#5223)
close: #3528

part of #4746
2024-08-30 11:11:04 +00:00
Boshen
8d6b05ca01 fix(transformer): class property with typescript value should not be removed (#5298) 2024-08-28 13:53:41 +00:00
Dunqing
292d162b23 feat(codegen): print missing fields for AccessorProperty (#5291)
Found in https://github.com/oxc-project/monitor-oxc/actions/runs/10592050362/job/29350666018
2024-08-28 08:42:39 +00:00
Dunqing
5754c89b5e fix(transformer/typescript): remove accessibility from AccessorProperty (#5292)
Regression by #5290
2024-08-28 08:42:38 +00:00
leaysgur
15b87adb05 chore(regular_expression): Extract diagnostics (#5287)
- Extract `Diagnostic::error()`s to separate file
- Align error message prefix
2024-08-28 03:19:29 +00:00
Boshen
e6fd52e2a6 fix(parser): change unterminated regex error to be non-recoverable (#5285)
closes #5257
2024-08-28 01:57:31 +00:00
overlookmotel
af5713e411 refactor(semantic): transform checker continue checks if missing IDs (#5259)
Transform checker don't bail out if some IDs missing from AST. Continue to check for other problems.

Also simplify iterating over pairs of IDs.
2024-08-27 11:58:20 +00:00
Boshen
a17cf33dc3 refactor(semantic): remove ScopeTree::child_ids (#5232)
closes https://github.com/oxc-project/oxc/issues/5244
2024-08-27 01:49:47 +00:00
leaysgur
1686920e23 fix(parser): Span for invalid regex flags (#5225)
### Before
```
  x Flag u is mentioned twice in regular expression literal
   ,-[1:20]
 1 | const a = /\2(.)/uuxig;
   :                    ^
 2 | debugger;
   `----

  x Unexpected flag x in regular expression literal
   ,-[1:21]
 1 | const a = /\2(.)/uuxig;
   :                     ^
 2 | debugger;
   `----
```

### After
```
  x Flag u is mentioned twice in regular expression literal
   ,-[1:19]
 1 | const a = /\2(.)/uuxig;
   :                   ^
 2 | debugger;
   `----

  x Unexpected flag x in regular expression literal
   ,-[1:20]
 1 | const a = /\2(.)/uuxig;
   :                    ^
 2 | debugger;
   `----
```
2024-08-26 10:24:47 +00:00
DonIsaac
7dfd51a62b feat(parser): report class properties that are both definite and optional (#5181) 2024-08-25 01:02:49 +00:00
DonIsaac
a563968386 feat(parser): report errors on optional accessor properties (#5180) 2024-08-25 01:02:49 +00:00
DonIsaac
c2fa72571f feat(ast,parser): parse TSTypeAnnotations on AccessorProperty (#5179)
Closes #5177

While making this, I noticed an uncaught parse error for accessors: accessors cannot be optional. I'll add a fix for this in an up-stack PR.
2024-08-25 01:02:48 +00:00
Boshen
c96609151e
fix(coverage): fix cases where source_type is incorrectly set to script 2024-08-24 14:40:05 +08:00
Boshen
e4ca3d3901
chore(coverage): ignore annex-b/disabled tests 2024-08-24 14:20:06 +08:00
Boshen
12c21b2bfd
fix(coverage): do not run generated test cases when filter is applied 2024-08-24 14:03:54 +08:00
Boshen
d5a494023e refactor(semantic): rewrite handling of label statement errors (#5138)
This reverts the previous changes to handling labels so that all tests can pass.

This passes all false postivies found in `monitor-oxc` (node_modules/flow-parser/flow_parser.js)

As it turns out this requires less code and produces better diagnostics.
2024-08-24 02:37:49 +00:00
overlookmotel
c100826b42 refactor(semantic)!: always create a scope for for statements (#5110)
Part of #5008. Make scopes for `ForStatement`, `ForInStatement` and `ForOfStatement` unconditional. i.e. always create a scope, even if there is no lexical binding (e.g. `for (i of a) {}`).
2024-08-23 09:28:13 +00:00
overlookmotel
91343913ca fix(semantic): transform checker check unresolved references (#5096)
Transform checker check root unresolved references.

The transform checker is now checking pretty much everything it can.

Only fields of `ScopeTree` and `SymbolTable` that it's *not* checking are those which contain `AstNodeId`s, because transformer does not create node IDs at present:

* `ScopeTree::node_ids`
* `SymbolTable::declarations`
* `Reference::node_id`

Checking also only proceeds in "from AST" direction.

i.e. for each `SymbolId` which appears in the AST, we check everything about that symbol. But we *don't* go through all the "rows" in `SymbolTable` and check if there are any extra symbols in the table which aren't in the AST.

Presumably transformer will leave a lot of old symbols lying around in `SymbolTable` (ditto scopes and references). We'd need to add `ScopeFlags::Deleted`, `SymbolFlags::Deleted` and `ReferenceFlags::Deleted` for the transformer to be able to "delete" existing symbols.
2024-08-23 07:52:30 +00:00
overlookmotel
c57e078c71 fix(semantic): transform checker check unbound references (#5093) 2024-08-23 08:37:48 +01:00
heygsc
ad2be97078
fix(semantic): incorrect semantic check for label has same name (#5041)
fix: #5036

---------

Co-authored-by: Boshen <boshenc@gmail.com>
2024-08-23 10:36:12 +08:00
overlookmotel
d5de97d6fe fix(semantic): transform checker check reference flags (#5092) 2024-08-23 00:21:21 +00:00
overlookmotel
9da6a21e40 refactor(semantic): rename transform checker output for reference symbol mismatches (#5091) 2024-08-22 23:40:27 +00:00
overlookmotel
90c74ee449 fix(semantic): transform checker check reference symbol IDs (#5090)
Previously was checking that references point to symbols with same name, but not necessarily the same symbol (there could be 2 different symbols with same name).
2024-08-22 23:40:26 +00:00
overlookmotel
a8005b9914 fix(semantic): transform checker check symbol redeclarations (#5089) 2024-08-22 23:40:26 +00:00
overlookmotel
205bff7ea9 fix(semantic): transform checker check symbol references (#5088) 2024-08-22 23:40:25 +00:00
overlookmotel
ea7d2163e3 fix(semantic): transform checker check symbol spans (#5076) 2024-08-22 15:08:47 +00:00
overlookmotel
1b6b27a6de fix(semantic): transform checker check symbol flags (#5074) 2024-08-22 15:08:45 +00:00
Boshen
6d87b0f1f2 fix(semantic): fix error message for duplicated label (#5071) 2024-08-22 12:30:04 +00:00
Boshen
afe728a73a feat(parser): parse regular expression with regex parser (#4998)
Many false positives and incorrect errors. @leaysgur Enjoy 😁

Run `just conformance` to update the snapshot.
2024-08-22 03:09:55 +00:00
overlookmotel
05fff16d55 fix(semantic): transform checker compare binding symbol IDs (#5057) 2024-08-22 02:34:44 +00:00
overlookmotel
f187b71877 fix(semantic): transform checker compare scope children (#5056) 2024-08-22 02:34:44 +00:00
overlookmotel
da64014a6c fix(semantic): transform checker catch more scope flags mismatches (#5054)
There was a bug previously where scope flags were only checked if there was also a bindings mismatch.
2024-08-22 02:34:43 +00:00
overlookmotel
67d1a96391 fix(semantic): transform checker compare scope flags (#5052) 2024-08-22 02:34:41 +00:00
overlookmotel
ee7ac8b0b7 refactor(semantic): store all data in PostTransformChecker in transform checker (#5050)
Pure refactor of transform checker. Store all scope data in `PostTransformChecker` so it doesn't need to be passed around. `SemanticData` contains a full set of all semantic data for semantic pass, so we have 2 instances of it for 1. after transform and 2. rebuilt semantic.
2024-08-21 17:04:48 +00:00
overlookmotel
4e1f4abf89 refactor(semantic): add SemanticIds to transformer checker (#5048)
Transformer checker use `SemanticIds` to store collected IDs. `SemanticIds` only contains the IDs, without the `Vec` of errors which is only used temporarily.
2024-08-21 15:49:07 +00:00
overlookmotel
8cded08eb8 refactor(semantic): rename error labels in transformer checker snapshots (#5044)
Rename labels in transformer checker snapshots "after transform" vs "rebuilt".
2024-08-21 14:33:19 +00:00
overlookmotel
586e15c814 refactor(semantic): reformat transform checker errors (#5039)
Reformat transform checker error output - shorter and consistent capitalization.
2024-08-21 12:07:11 +00:00
Boshen
1bd9365bd0 fix(coverage): correctly check semantic data after transform (#5035)
closes #4999
2024-08-21 09:35:04 +00:00
Boshen
b4407c4e9a
refactor(oxc,mangler): oxc crate add mangler; mangler use options API 2024-08-20 22:58:59 +08:00
Boshen
cd9cf5efd8
refactor(oxc): remove remove_whitespace 2024-08-20 18:27:59 +08:00
Boshen
1f6b107339 chore(coverage): ignore test262 stage3 json-modules (#5002)
stage 3 https://github.com/tc39/proposal-json-modules

Ignoring due to https://github.com/tc39/proposal-json-modules/issues/27
2024-08-20 08:50:27 +00:00
Boshen
b2ff2df5af refactor(parser)!: remove builder pattern from Parser struct (#5000)
part of #4455

use `with_options(ParseOptions { ..ParseOptions::default() })` API instead.
2024-08-20 07:40:25 +00:00
Burlin
f88970bc79
refactor(ast)!: Change order of fields in CallExpression (#4859)
fix: #4821

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-08-20 09:47:12 +08:00
Boshen
3f6014a042 chore(semantic): add PostTransformChecker (#4967) 2024-08-19 05:38:27 +00:00
Boshen
6800e694e3
feat(oxc): add Compiler and CompilerInterface (#4954)
This PR adds a full compiler pipeline to the `oxc` crate, to stop us
from implementing the same pipeline over and over again.

relates #4455
2024-08-19 10:20:05 +08:00
Boshen
c7a86865f3
fix(coverage): handle transformer errors 2024-08-18 22:19:58 +08:00
Boshen
873d502993
refactor(coverage): use the oxc crate 2024-08-17 22:40:08 +08:00