Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Nov 25, 2024

close #7402
related: #7470

The purpose of this PR is to keep the SymbolFlags of the function consistent.

Always use SymbolFlags::Function for the function id symbol, to avoid adding extra logic to find accurate SymbolFlags for the function in transformer. This change adds a fallback redeclaration check for case async function foo() {}; var foo; in SemanticBuilder::check_redeclaraion.

No performance difference here because redeclaration is always rare.

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 25, 2024

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

Add the label “0-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.

@github-actions github-actions bot added A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Nov 25, 2024
Copy link
Member Author

Dunqing commented Nov 25, 2024


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 25, 2024

CodSpeed Instrumentation Performance Report

Merging #7479 will not alter performance

Comparing 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id (0fa58d7) with main (be62d38)

Summary

✅ 28 untouched benchmarks
🆕 5 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 lexer[RadixUIAdoptionSection.jsx] N/A 21.2 µs N/A
🆕 lexer[antd.js] N/A 24.8 ms N/A
🆕 lexer[cal.com.tsx] N/A 5.9 ms N/A
🆕 lexer[checker.ts] N/A 14.8 ms N/A
🆕 lexer[pdf.mjs] N/A 3.9 ms N/A

@Dunqing Dunqing changed the title refactor(semantic): keep consistent SymbolFlags for function id refactor(semantic): always use SymbolFlags::Function for function id Nov 26, 2024
@Dunqing Dunqing force-pushed the 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id branch from 93b94c7 to 70d22c4 Compare November 26, 2024 07:46
@github-actions github-actions bot added the A-ast Area - AST label Nov 26, 2024
@Dunqing Dunqing force-pushed the 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id branch from 70d22c4 to 69e66d3 Compare November 26, 2024 07:54
@github-actions github-actions bot added the A-linter Area - Linter label Nov 26, 2024
@Dunqing Dunqing marked this pull request as ready for review November 26, 2024 07:55
@Dunqing Dunqing requested a review from Boshen as a code owner November 26, 2024 07:55
@Dunqing Dunqing force-pushed the 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id branch 2 times, most recently from 5acbe14 to f40c689 Compare November 26, 2024 09:43
@Boshen Boshen self-assigned this Nov 27, 2024
@Boshen Boshen force-pushed the 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id branch 2 times, most recently from 90c06bb to 76d7e62 Compare November 28, 2024 10:53
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Nov 28, 2024
Copy link
Member

Boshen commented Nov 28, 2024

Merge activity

  • Nov 28, 5:54 AM EST: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Nov 29, 12:14 AM EST: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Nov 29, 12:14 AM EST: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 24, 4:50 AM EDT: A user added this pull request to the Graphite merge queue.
  • Mar 24, 4:58 AM EDT: A user merged this pull request with the Graphite merge queue.

@Boshen Boshen force-pushed the 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id branch 3 times, most recently from cd8ff8c to 24da206 Compare November 28, 2024 11:33
@overlookmotel
Copy link
Member

Can we possibly discuss this before merging? Personally, I'm not convinced this is a good idea.

@Boshen Boshen force-pushed the 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id branch from 24da206 to 2fb06c0 Compare November 28, 2024 13:03
@Boshen Boshen added the needs-discussion Requires a discussion from the core team label Nov 29, 2024
@Boshen Boshen marked this pull request as draft November 29, 2024 10:16
@Boshen
Copy link
Member

Boshen commented Nov 29, 2024

// TODO: Needs a better way to handle the function SymbolFlags in different ModuleKind.
let flags = if self.ctx.source_type.is_module() && ctx.current_scope_flags().is_top() {
SymbolFlags::BlockScopedVariable | SymbolFlags::Function
} else {
SymbolFlags::FunctionScopedVariable
};

@Dunqing Dunqing marked this pull request as ready for review March 24, 2025 08:50
#7479)

close #7402
related: #7470

The purpose of this PR is to keep the SymbolFlags of the function consistent.

Always use `SymbolFlags::Function` for the function id symbol, to avoid adding extra logic to find accurate `SymbolFlags` for the function in `transformer`. This change adds a fallback redeclaration check for case `async function foo() {}; var foo;` in `SemanticBuilder::check_redeclaraion`.

No performance difference here because redeclaration is always rare.
@graphite-app graphite-app bot force-pushed the 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id branch from 78531f5 to 0fa58d7 Compare March 24, 2025 08:51
@graphite-app graphite-app bot merged commit 0fa58d7 into main Mar 24, 2025
28 checks passed
@graphite-app graphite-app bot deleted the 11-26-refactor_semantic_keep_consistent_symbolflags_for_function_id branch March 24, 2025 08:58
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 24, 2025
This was referenced Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-linter Area - Linter A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior needs-discussion Requires a discussion from the core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants