fix(biome_js_semantic): fix incorrect semantic resolution of arguments object#7671
fix(biome_js_semantic): fix incorrect semantic resolution of arguments object#7671qraqras wants to merge 1 commit intobiomejs:mainfrom
arguments object#7671Conversation
🦋 Changeset detectedLatest commit: a35d661 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis PR updates scope tracking and reference binding in the semantic layer to carry scope range and kind, changes push/pop scope signatures, and adds logic to correctly bind/promote references to the built-in arguments across function scopes. Scope-ended events now emit the stored range. Test infrastructure can parse as script when prefixed with // @script. New tests cover arguments resolution across function forms and nesting, plus updated noArguments valid/invalid samples. A changeset records a patch for @biomejs/biome documenting the fix to noArguments scoping of arguments. Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
crates/biome_js_analyze/tests/specs/complexity/noArguments/invalid.cjs.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/complexity/noArguments/valid.cjs.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (6)
.changeset/every-baths-dream.md(1 hunks)crates/biome_js_analyze/tests/specs/complexity/noArguments/invalid.cjs(2 hunks)crates/biome_js_analyze/tests/specs/complexity/noArguments/valid.cjs(1 hunks)crates/biome_js_semantic/src/events.rs(21 hunks)crates/biome_js_semantic/src/tests/assertions.rs(2 hunks)crates/biome_js_semantic/src/tests/references.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_js_semantic/src/tests/assertions.rscrates/biome_js_semantic/src/tests/references.rscrates/biome_js_analyze/tests/specs/complexity/noArguments/valid.cjscrates/biome_js_semantic/src/events.rscrates/biome_js_analyze/tests/specs/complexity/noArguments/invalid.cjs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_semantic/src/tests/assertions.rscrates/biome_js_semantic/src/tests/references.rscrates/biome_js_analyze/tests/specs/complexity/noArguments/valid.cjscrates/biome_js_semantic/src/events.rscrates/biome_js_analyze/tests/specs/complexity/noArguments/invalid.cjs
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_js_semantic/src/tests/assertions.rscrates/biome_js_semantic/src/tests/references.rscrates/biome_js_analyze/tests/specs/complexity/noArguments/valid.cjscrates/biome_js_analyze/tests/specs/complexity/noArguments/invalid.cjs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_js_semantic/src/tests/assertions.rscrates/biome_js_semantic/src/tests/references.rscrates/biome_js_semantic/src/events.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_semantic/src/tests/assertions.rscrates/biome_js_semantic/src/tests/references.rscrates/biome_js_semantic/src/events.rs
.changeset/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/**/*.md: Create changesets using thejust new-changesetcommand; do not author them manually
In changeset markdown, only use headers #### or #####
Changeset descriptions must end every sentence with a full stop (.)
For bug fixes, start the changeset description with a linked issue reference like “Fixed #1234”
Prefer past tense for what was done and present tense for current behavior in changesets
Files:
.changeset/every-baths-dream.md
🧬 Code graph analysis (4)
crates/biome_js_semantic/src/tests/assertions.rs (2)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
JsFileSource(9361-9370)crates/biome_js_factory/src/generated/node_factory.rs (1)
js_script(3122-3134)
crates/biome_js_analyze/tests/specs/complexity/noArguments/valid.cjs (1)
crates/biome_js_analyze/tests/specs/complexity/noArguments/invalid.cjs (2)
arguments(1-1)arguments(14-14)
crates/biome_js_semantic/src/events.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
TextRange(9205-9205)
crates/biome_js_analyze/tests/specs/complexity/noArguments/invalid.cjs (1)
crates/biome_js_analyze/tests/specs/complexity/noArguments/valid.cjs (1)
arguments(3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: Parser conformance
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Test Node.js API
- GitHub Check: Documentation
- GitHub Check: End-to-end tests
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: autofix
🔇 Additional comments (4)
crates/biome_js_semantic/src/tests/references.rs (4)
205-212: LGTM! Test correctly verifiesargumentsscoping in function declarations.The test properly demonstrates that
argumentswithin a function declaration should remain unresolved (not bind to outer scope), whilstfoocorrectly resolves to the outer binding.
213-220: LGTM! Validatesargumentsscoping for function expressions.Correctly parallels the function declaration test, confirming that function expressions also treat
argumentsas implicitly scoped.
221-226: LGTM! Correctly validates arrow function semantics.Arrow functions do not bind
arguments, so the reference correctly resolves to the outer scope. Nice distinction from regular functions.
227-243: LGTM! Comprehensive test for nested function scoping.The test thoroughly validates that
argumentsin nested functions remains unresolved (implicitly scoped per function), whilst localargumentsvariables are correctly resolved when referenced. Excellent coverage of the shadowing scenario.
CodSpeed Performance ReportMerging #7671 will not alter performanceComparing Summary
Footnotes
|
Summary
Closes #7628
The
argumentsobject was incorrectly resolved to outer scope declarations, even though it implicitly exists within functions.This PR ensures that the
argumentsobject is resolved only within the function.As a result, #7628 will be resolved.
Before:
After:
Please feel free to give feedback if tests are lacking or hard to read.
Test Plan
Docs