Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(semantic): align class scope with typescript #4195

Merged

Conversation

Dunqing
Copy link
Member

@Dunqing Dunqing commented Jul 11, 2024

class Klass <T>   extends Root       <R>                   {}
//    ^^^^^ ^^^           ^^^^       ^^^                   ^^
//    id type_paramter super_class super_type_parameters  body

I reorder fields according to the order above

The class scope is not defined in the spec. But we need to create a scope for class to store TypeParamters

Copy link

graphite-app bot commented Jul 11, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Member Author

Dunqing commented Jul 11, 2024

Copy link

codspeed-hq bot commented Jul 11, 2024

CodSpeed Performance Report

Merging #4195 will not alter performance

Comparing 07-11-feat_semantic_align_class_scope_with_typescript (20cdb1f) with main (ab41c52)

Summary

✅ 32 untouched benchmarks

@Boshen Boshen force-pushed the 07-11-refactor_semantic_set_current_scope_id_to_scope_id_in_enter_scope branch from 27cacf3 to bbe5ded Compare July 11, 2024 08:46
@Dunqing Dunqing force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch from f5a2d06 to 2634b62 Compare July 11, 2024 08:51
@Boshen Boshen changed the base branch from 07-11-refactor_semantic_set_current_scope_id_to_scope_id_in_enter_scope to main July 11, 2024 08:54
@Dunqing Dunqing force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch from 2634b62 to 7fe477a Compare July 11, 2024 09:21
@github-actions github-actions bot added A-linter Area - Linter A-transformer Area - Transformer / Transpiler labels Jul 11, 2024
@overlookmotel
Copy link
Collaborator

The class scope is not defined in the spec

I think it is - please see #4161.

@Dunqing Dunqing force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch 2 times, most recently from 3f07793 to c28059f Compare July 11, 2024 10:39
@Dunqing
Copy link
Member Author

Dunqing commented Jul 11, 2024

Blocked on #4200

@Dunqing Dunqing force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch 2 times, most recently from 1191d63 to a6ebc10 Compare July 12, 2024 04:48
@Dunqing Dunqing mentioned this pull request Jul 12, 2024
@Dunqing
Copy link
Member Author

Dunqing commented Jul 12, 2024

The regression tests have been fixed in #4156. Should I merge into this PR?

@Dunqing Dunqing force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch 2 times, most recently from 262b724 to 2eb37d5 Compare July 12, 2024 08:11
@Dunqing Dunqing marked this pull request as draft July 13, 2024 00:47
Copy link
Member Author

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not adding symbols to scope may cause some confusion. For example, in mangler, we need to rename bindings, but we can't find the symbols for function expression and class expression in scope.

I'll revert this change

@Dunqing Dunqing force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch from 46a5f29 to 04cffb4 Compare July 13, 2024 17:17
@Dunqing Dunqing marked this pull request as ready for review July 13, 2024 17:24
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Jul 14, 2024
Copy link

graphite-app bot commented Jul 14, 2024

Merge activity

  • Jul 13, 11:11 PM EDT: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 13, 11:15 PM EDT: Boshen added this pull request to the Graphite merge queue.
  • Jul 13, 11:23 PM EDT: Boshen merged this pull request with the Graphite merge queue.

Boshen pushed a commit that referenced this pull request Jul 14, 2024
```ts
class Klass <T>   extends Root       <R>                   {}
//    ^^^^^ ^^^           ^^^^       ^^^                   ^^
//    id type_paramter super_class super_type_parameters  body
```
I reorder fields according to the order above

The class scope is not defined in the spec. But we need to create a scope for `class` to store `TypeParamters`
@Boshen Boshen force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch from 04cffb4 to d9035f9 Compare July 14, 2024 03:17
@Dunqing Dunqing force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch from d9035f9 to 9adbb61 Compare July 14, 2024 03:18
```ts
class Klass <T>   extends Root       <R>                   {}
//    ^^^^^ ^^^           ^^^^       ^^^                   ^^
//    id type_paramter super_class super_type_parameters  body
```
I reorder fields according to the order above

The class scope is not defined in the spec. But we need to create a scope for `class` to store `TypeParamters`
@Boshen Boshen force-pushed the 07-11-feat_semantic_align_class_scope_with_typescript branch from 9adbb61 to 20cdb1f Compare July 14, 2024 03:19
@graphite-app graphite-app bot merged commit 20cdb1f into main Jul 14, 2024
27 checks passed
@graphite-app graphite-app bot deleted the 07-11-feat_semantic_align_class_scope_with_typescript branch July 14, 2024 03:23
Boshen pushed a commit that referenced this pull request Jul 14, 2024
…fields in the builder to be consistent (#4248)

Same as #4195
This was referenced Jul 17, 2024
Boshen added a commit that referenced this pull request Jul 17, 2024
## [0.6.1] - 2024-07-17

### Features

- 83c2c62 codegen: Add option for choosing quotes; remove slow
`choose_quot` method (#4219) (Boshen)
- 1f8968a linter: Add eslint-plugin-promise rules: avoid-new,
no-new-statics, params-names (#4293) (Jelle van der Waa)
- a4dc56c linter: Add fixer for
unicorn/no_useless_promise_resolve_reject (#4244) (Burlin)
- 6fb808f linter: Add typescript-eslint/no-confusing-non-null-assertion
(#4224) (Jaden Rodriguez)
- 126b66c linter: Support eslint-plugin-vitest/valid-describe-callback
(#4185) (cinchen)
- 05b9a73 linter: Support eslint-plugin-vitest/valid-expect (#4183)
(cinchen)
- 3e56b2b linter: Support eslint-plugin-vitest/no-test-prefixes (#4182)
(cinchen)
- 3016f03 linter: Let fixer functions return a `None` fix (#4210)
(DonIsaac)
- bbe6137 linter: Implement unicorn/no-useless-undefined (#4079)
(Burlin)
- 20cdb1f semantic: Align class scope with typescript (#4195) (Dunqing)

### Bug Fixes

- 9df60da linter: Correct find first non whitespace logic in
@typescript-eslint/consistent-type-imports (#4198) (mysteryven)
- 67240dc linter: Not ignore adjacent spans when fixing (#4217)
(mysteryven)
- dd07a54 linter: Global variables should always check the builtin
variables (#4209) (Jelle van der Waa)
- 351ecf2 semantic: Incorrect resolve references for `TSTypeQuery`
(#4310) (Dunqing)
- 1108f2a semantic: Resolve references to the incorrect symbol (#4280)
(Dunqing)

### Performance

- 0fdc88b linter: Optimize no-dupe-keys (#4292) (lucab)

### Refactor

- 2c7bb9f ast: Pass final `ScopeFlags` into `visit_function` (#4283)
(overlookmotel)
- aa22073 codegen: Improve print API (#4196) (Boshen)
- b5a8f3c linter: Use get_first_parameter_name from unicorn utils
(#4255) (Jelle van der Waa)
- 7089a3d linter: Split up fixer code into separate files (#4222)
(DonIsaac)
- ace4f1f semantic: Update the order of `visit_function` and `Visit`
fields in the builder to be consistent (#4248) (Dunqing)
- 7f1addd semantic: Correct scope in CatchClause (#4192) (Dunqing)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
@github-actions github-actions bot mentioned this pull request Jul 18, 2024
Dunqing pushed a commit that referenced this pull request Jul 18, 2024
## [0.21.0] - 2024-07-18

- d7ab0b8 semantic: [**BREAKING**] Simplify node creation (#4226)
(lucab)

### Features

- af4dc01 ast: Align ts ast scope with typescript (#4253) (Dunqing)
- 83c2c62 codegen: Add option for choosing quotes; remove slow
`choose_quot` method (#4219) (Boshen)
- 5d17675 mangler: Add debug mode (#4314) (Boshen)
- e3e663b mangler: Initialize crate and integrate into minifier (#4197)
(Boshen)
- c818472 minifier: Dce conditional expression `&&` or `||` (#4190)
(Boshen)
- 8a190eb oxc: Export `oxc_mangler` (Boshen)
- 20cdb1f semantic: Align class scope with typescript (#4195) (Dunqing)
- 92ee774 semantic: Add `ScopeFlags::CatchClause` for use in CatchClause
(#4205) (Dunqing)
- 205c259 sourcemap: Support SourceMapBuilder#token_chunks (#4220)
(underfin)
- 7eb960d transformer: Decode xml character entity `&#xhhhh` and
`&#nnnn;` (#4235) (Boshen)

### Bug Fixes

- bf3d8d3 codegen: Print annotation comment inside parens for new and
call expressions (#4290) (Boshen)
- 084ab76 codegen: Use `ryu-js` for f64 to string (Boshen)
- e167ef7 codegen: Print parenthesis properly (#4245) (Boshen)
- c65198f codegen: Choose the right quote for jsx attribute string
(#4236) (Boshen)
- be82c28 codegen: Print `JSXAttributeValue::StringLiteral` directly
(#4231) (Boshen)
- 3df9e69 mangler: No shorthand `BindingProperty`; handle var hoisting
and export variables (#4319) (Boshen)
- f144082 minifier: RemoveDeadCode should visit nested expression
(#4268) (underfin)
- 66b455a oxc_codegen: Avoid print same pure comments multiple time
(#4230) (IWANABETHATGUY)
- 9a87e41 parser: Avoid crashing on invalid const modifier (#4267)
(lucab)
- 641a78b parser: Fix tests for number parsing (#4254) (overlookmotel)
- 9badac0 semantic: Avoid var hosting insert the var variable to the
`CatchClause` scope (#4337) (Dunqing)
- 95e15b6 semantic: Incorrect resolve references for `ExportSpecifier`
(#4320) (Dunqing)
- c362bf7 semantic: Incorrect resolve references for
`TSInterfaceHeritage` (#4311) (Dunqing)
- 351ecf2 semantic: Incorrect resolve references for `TSTypeQuery`
(#4310) (Dunqing)
- 1108f2a semantic: Resolve references to the incorrect symbol (#4280)
(Dunqing)
- 22d56bd semantic: Do not resolve references after `FormalParameters`
in TS type (#4241) (overlookmotel)- 1c117eb Avoid print extra semicolon
after accessor property (#4199) (IWANABETHATGUY)

### Performance

- a8dc4f3 parser: Speed up parsing numbers with `_` separators (#4259)
(overlookmotel)
- b94540d parser: Speed up parsing octal literals (#4258)
(overlookmotel)
- a7b328c parser: Faster parsing decimal numbers (#4257) (overlookmotel)
- f9d3f2e semantic: Inline ast record functions (#4272) (overlookmotel)
- 8fad7db semantic: Reduce `AstNodeId` to `u32` (#4264) (overlookmotel)
- 23743db semantic: Do not record ast nodes for cfg if cfg disabled
(#4263) (overlookmotel)
- da69076 semantic: Reduce overhead of cfg recording ast nodes (#4262)
(overlookmotel)
- cb15303 semantic: Reduce memory copies (#4216) (overlookmotel)
- ef4c1f4 semantic: Reduce lookups (#4214) (overlookmotel)
- f23e54f semantic: Recycle unresolved references hash maps (#4213)
(overlookmotel)
- 2602ce2 semantic: Reuse existing map of unresolved refs (#4206)
(lucab)

### Refactor

- 2c7bb9f ast: Pass final `ScopeFlags` into `visit_function` (#4283)
(overlookmotel)
- 3e099fe ast: Move `enter_scope` after `visit_binding_identifier`
(#4246) (Dunqing)
- aab7aaa ast/visit: Fire node events as the outermost one. (#4203)
(rzvxa)
- d1c4be0 codegen: Clean up annotation_comment (Boshen)
- 06197b8 codegen: Separate tests (Boshen)
- aa22073 codegen: Improve print API (#4196) (Boshen)
- c5731a5 semantic: Remove defunct code setting ScopeFlags twice (#4286)
(overlookmotel)
- 16698bc semantic: Move function/class-specific code into specific
visitors (#4278) (overlookmotel)
- ee16668 semantic: Rename function param (#4277) (overlookmotel)
- 25f0771 semantic: Alter syntax of `control_flow!` macro (#4275)
(overlookmotel)
- 639fd48 semantic: Comment why extra CFG enabled check (#4274)
(overlookmotel)
- c418bf5 semantic: Directly record `current_node_id` when adding a
scope (#4265) (Dunqing)
- ace4f1f semantic: Update the order of `visit_function` and `Visit`
fields in the builder to be consistent (#4248) (Dunqing)
- 8bfeabf semantic: Simplify adding `SymbolFlags::Export` (#4249)
(Dunqing)
- dc2b3c4 semantic: Add strict mode in scope flags for class definitions
(#4156) (Dunqing)
- 81ed588 semantic: Convert scope fields to IndexVecs (#4208) (lucab)
- bbe5ded semantic: Set `current_scope_id` to `scope_id` in
`enter_scope` (#4193) (Dunqing)
- 7f1addd semantic: Correct scope in CatchClause (#4192) (Dunqing)
- fc0b17d syntax: Turn the `AstNodeId::dummy` into a constant field.
(#4308) (rzvxa)
- a197e01 transformer/typescript: Remove unnecessary code (#4321)
(Dunqing)
- 1458d81 visit: Add `#[inline]` to empty functions (#4330)
(overlookmotel)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
@github-actions github-actions bot mentioned this pull request Jul 18, 2024
Dunqing pushed a commit that referenced this pull request Jul 18, 2024
## [0.21.0] - 2024-07-18

- d7ab0b8 semantic: [**BREAKING**] Simplify node creation (#4226)
(lucab)

### Features

- af4dc01 ast: Align ts ast scope with typescript (#4253) (Dunqing)
- 83c2c62 codegen: Add option for choosing quotes; remove slow
`choose_quot` method (#4219) (Boshen)
- 5d17675 mangler: Add debug mode (#4314) (Boshen)
- e3e663b mangler: Initialize crate and integrate into minifier (#4197)
(Boshen)
- c818472 minifier: Dce conditional expression `&&` or `||` (#4190)
(Boshen)
- 8a190eb oxc: Export `oxc_mangler` (Boshen)
- 20cdb1f semantic: Align class scope with typescript (#4195) (Dunqing)
- 92ee774 semantic: Add `ScopeFlags::CatchClause` for use in CatchClause
(#4205) (Dunqing)
- 205c259 sourcemap: Support SourceMapBuilder#token_chunks (#4220)
(underfin)
- 7eb960d transformer: Decode xml character entity `&#xhhhh` and
`&#nnnn;` (#4235) (Boshen)

### Bug Fixes

- bf3d8d3 codegen: Print annotation comment inside parens for new and
call expressions (#4290) (Boshen)
- 084ab76 codegen: Use `ryu-js` for f64 to string (Boshen)
- e167ef7 codegen: Print parenthesis properly (#4245) (Boshen)
- c65198f codegen: Choose the right quote for jsx attribute string
(#4236) (Boshen)
- be82c28 codegen: Print `JSXAttributeValue::StringLiteral` directly
(#4231) (Boshen)
- 3df9e69 mangler: No shorthand `BindingProperty`; handle var hoisting
and export variables (#4319) (Boshen)
- f144082 minifier: RemoveDeadCode should visit nested expression
(#4268) (underfin)
- 66b455a oxc_codegen: Avoid print same pure comments multiple time
(#4230) (IWANABETHATGUY)
- 9a87e41 parser: Avoid crashing on invalid const modifier (#4267)
(lucab)
- 641a78b parser: Fix tests for number parsing (#4254) (overlookmotel)
- 9badac0 semantic: Avoid var hosting insert the var variable to the
`CatchClause` scope (#4337) (Dunqing)
- 95e15b6 semantic: Incorrect resolve references for `ExportSpecifier`
(#4320) (Dunqing)
- c362bf7 semantic: Incorrect resolve references for
`TSInterfaceHeritage` (#4311) (Dunqing)
- 351ecf2 semantic: Incorrect resolve references for `TSTypeQuery`
(#4310) (Dunqing)
- 1108f2a semantic: Resolve references to the incorrect symbol (#4280)
(Dunqing)
- 22d56bd semantic: Do not resolve references after `FormalParameters`
in TS type (#4241) (overlookmotel)- 1c117eb Avoid print extra semicolon
after accessor property (#4199) (IWANABETHATGUY)

### Performance

- a8dc4f3 parser: Speed up parsing numbers with `_` separators (#4259)
(overlookmotel)
- b94540d parser: Speed up parsing octal literals (#4258)
(overlookmotel)
- a7b328c parser: Faster parsing decimal numbers (#4257) (overlookmotel)
- f9d3f2e semantic: Inline ast record functions (#4272) (overlookmotel)
- 8fad7db semantic: Reduce `AstNodeId` to `u32` (#4264) (overlookmotel)
- 23743db semantic: Do not record ast nodes for cfg if cfg disabled
(#4263) (overlookmotel)
- da69076 semantic: Reduce overhead of cfg recording ast nodes (#4262)
(overlookmotel)
- cb15303 semantic: Reduce memory copies (#4216) (overlookmotel)
- ef4c1f4 semantic: Reduce lookups (#4214) (overlookmotel)
- f23e54f semantic: Recycle unresolved references hash maps (#4213)
(overlookmotel)
- 2602ce2 semantic: Reuse existing map of unresolved refs (#4206)
(lucab)

### Refactor

- 2c7bb9f ast: Pass final `ScopeFlags` into `visit_function` (#4283)
(overlookmotel)
- 3e099fe ast: Move `enter_scope` after `visit_binding_identifier`
(#4246) (Dunqing)
- aab7aaa ast/visit: Fire node events as the outermost one. (#4203)
(rzvxa)
- d1c4be0 codegen: Clean up annotation_comment (Boshen)
- 06197b8 codegen: Separate tests (Boshen)
- aa22073 codegen: Improve print API (#4196) (Boshen)
- c5731a5 semantic: Remove defunct code setting ScopeFlags twice (#4286)
(overlookmotel)
- 16698bc semantic: Move function/class-specific code into specific
visitors (#4278) (overlookmotel)
- ee16668 semantic: Rename function param (#4277) (overlookmotel)
- 25f0771 semantic: Alter syntax of `control_flow!` macro (#4275)
(overlookmotel)
- 639fd48 semantic: Comment why extra CFG enabled check (#4274)
(overlookmotel)
- c418bf5 semantic: Directly record `current_node_id` when adding a
scope (#4265) (Dunqing)
- ace4f1f semantic: Update the order of `visit_function` and `Visit`
fields in the builder to be consistent (#4248) (Dunqing)
- 8bfeabf semantic: Simplify adding `SymbolFlags::Export` (#4249)
(Dunqing)
- dc2b3c4 semantic: Add strict mode in scope flags for class definitions
(#4156) (Dunqing)
- 81ed588 semantic: Convert scope fields to IndexVecs (#4208) (lucab)
- bbe5ded semantic: Set `current_scope_id` to `scope_id` in
`enter_scope` (#4193) (Dunqing)
- 7f1addd semantic: Correct scope in CatchClause (#4192) (Dunqing)
- fc0b17d syntax: Turn the `AstNodeId::dummy` into a constant field.
(#4308) (rzvxa)
- a197e01 transformer/typescript: Remove unnecessary code (#4321)
(Dunqing)
- 1458d81 visit: Add `#[inline]` to empty functions (#4330)
(overlookmotel)

Co-authored-by: Boshen <Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0-merge Merge with Graphite Merge Queue A-ast Area - AST A-isolated-declarations Isolated Declarations A-linter Area - Linter A-parser Area - Parser A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants