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

Support exiting scope before last field #[scope(exit_before)] #6311

Closed
overlookmotel opened this issue Oct 6, 2024 · 3 comments · Fixed by #6350
Closed

Support exiting scope before last field #[scope(exit_before)] #6311

overlookmotel opened this issue Oct 6, 2024 · 3 comments · Fixed by #6350
Assignees
Labels
A-ast-tools Area - AST tools C-enhancement Category - New feature or request

Comments

@overlookmotel
Copy link
Contributor

oxc_ast_tools recognises #[scope(enter_before)] to mark a field as the start of the scope in a type. We also need #[scope(exit_before)] for #6270.

Note: I think #[scope(exit_before)] is better than #[scope(exit_after)] because attributes go before fields, so it reads more clearly:

pub struct TSConditionalType<'a> {
    pub span: Span,
    pub check_type: TSType<'a>,
    #[scope(enter_before)]
    pub extends_type: TSType<'a>,
    pub true_type: TSType<'a>,
    #[scope(exit_before)]
    pub false_type: TSType<'a>,
    pub scope_id: Cell<Option<ScopeId>>,
}

We will need to build support for this into both:

  1. oxc_ast_tools and the Visit / VisitMut generator.
  2. oxc_traverse's codegen.
@overlookmotel overlookmotel added the A-ast-tools Area - AST tools label Oct 6, 2024
@overlookmotel
Copy link
Contributor Author

@DonIsaac Rzvxa is the master of the codegen, but is off radar at the moment, and I'm not sure when I'd get to it. You comfortable enough with oxc_ast_tools to implement yourself?

@DonIsaac
Copy link
Contributor

DonIsaac commented Oct 6, 2024

I'm not very comfortable, but I can take a look and try it out.

@DonIsaac DonIsaac added the C-enhancement Category - New feature or request label Oct 6, 2024
@DonIsaac DonIsaac self-assigned this Oct 7, 2024
Boshen pushed a commit that referenced this issue Oct 9, 2024
Closes #6311.

Adds support for `#[scope(exit_before)]`, which is the opposite of `#[scope(enter_before)]`
@overlookmotel
Copy link
Contributor Author

Implemented in #6350. Thanks Don!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast-tools Area - AST tools C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants