Skip to content

Add parser support for explicit resource management (using/await using) - #4649

Merged
jedel1043 merged 16 commits into
boa-dev:mainfrom
abhinavs1920:feat/resource
Mar 13, 2026
Merged

jedel1043 merged 16 commits into
boa-dev:mainfrom
abhinavs1920:feat/resource

Conversation

@abhinavs1920

@abhinavs1920 abhinavs1920 commented Feb 21, 2026 •

Copy link
Copy Markdown
Contributor

This Pull Request fixes/closes #4445

This PR introduces the parser foundation for the TC39 Explicit Resource Management proposal. It’s an initial step and does not yet include runtime support, which will be added gradually in future commits. Because this is a large feature, it will be developed over multiple commits.

It focuses on parsing support for using and await using, along with proper validation, AST integration, and test coverage. Runtime behavior is intentionally not included yet, using declarations are currently compiled as regular lexical bindings, with clear TODOs marking the follow-up work.

All existing parser tests continue to pass, and 5 new tests have been added for the new syntax. An example script and a short implementation roadmap are included to make future work straightforward.

This is the first step of a larger feature and is designed to be safe, incremental, and easy to review. Runtime disposal logic and related built-ins will be added in further commits of my work.

Thanks for reviewing!

…t using)

Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
@github-actions

github-actions Bot commented Feb 21, 2026 •

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 49,935 49,935 0
Ignored 2,207 2,207 0
Failed 821 821 0
Panics 0 0 0
Conformance 94.28% 94.28% 0.00%

Tested main commit: d535eee21500b40d2e926d824993439df8eecc4d
Tested PR commit: 25c44ad59041fc0b1bfb67b47175fb69956e56ce
Compare commits: d535eee...25c44ad

@nekevss nekevss added A-Enhancement New feature or request labels Feb 24, 2026
@nekevss
nekevss requested a review from a team February 24, 2026 02:33
@jedel1043 jedel1043 added waiting-on-review C-Parser Issues surrounding the parser C-AST Issue surrounding the abstract syntax tree labels Feb 25, 2026

@jedel1043 jedel1043 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice job! This seems like a very good starting point for the feature.

Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
@abhinavs1920

Copy link
Copy Markdown
Contributor Author

Heyy @jedel1043, I have made the required updates.
Also updated the tests to verify both behaviors. All 302 parser tests pass now.

@abhinavs1920

Copy link
Copy Markdown
Contributor Author

So... I’m thinking of implementing the remaining implementation in separate PRs. Does that work for you, or would you prefer if I handle this iteratively in a single PR?

@jedel1043

Copy link
Copy Markdown
Member

Open up multiple PRs please, it makes reviewing much easier

Comment thread core/parser/src/parser/statement/mod.rs Resolved
}

// Check if this is `await using`
let next_tok = cursor.peek(0, interner).or_abrupt()?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doesn't this need to use peek_no_skip_line_term? According to the spec, await using is only valid if there are no line terminators between both keywords.

I would suggest you do a pass through the spec to see if you can find small caveats like these

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, I actually pushed this in the latest update 🙂 Went through the spec properly and added peek_no_skip_line_term() checks in all three spots (lexical.rs, declaration/mod.rs, and statement/mod.rs) with explicit line terminator validation. Also added solid test coverage for the no-line-terminator rule, destructuring rejection, AllowAwait checks, and the other early errors.

abhinavs1920 and others added 2 commits March 3, 2026 14:07

@jedel1043 jedel1043 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Amazing work! Can't wait to see the full proposal implemented

@jedel1043
jedel1043 enabled auto-merge March 6, 2026 07:13
@abhinavs1920

Copy link
Copy Markdown
Contributor Author

Hey @jedel1043, thanks for the review.

Could you run the CI tests so I can check if anything breaks? Also, I think we should have a setting to run the CI automatically once the changes are approved by the maintainer. This would help contributors run tests and make improvements more easily.

I’m also working on the next part of the proposal, but I need these changes to be merged first so I can open a new PR with the continued updates.

@jedel1043

Copy link
Copy Markdown
Member

I think we should have a setting to run the CI automatically once the changes are approved by the maintainer.

That's enabled, but only if you have at least a PR merged into the project

@jedel1043

Copy link
Copy Markdown
Member

You could just run tests locally if you want early feedback :)

@abhinavs1920

Copy link
Copy Markdown
Contributor Author

That's enabled, but only if you have at least a PR merged into the project

ohh.. that's understandable 😅

Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
auto-merge was automatically disabled March 7, 2026 18:17

Head branch was pushed to by a user without write access

@abhinavs1920
abhinavs1920 requested a review from jedel1043 March 7, 2026 18:27
@codecov

codecov Bot commented Mar 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 89 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.12%. Comparing base (6ddc2b4) to head (25c44ad).
⚠️ Report is 844 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/bytecompiler/mod.rs 0.00% 42 Missing ⚠️
...ore/parser/src/parser/statement/declaration/mod.rs 41.37% 17 Missing ⚠️
...parser/src/parser/statement/declaration/lexical.rs 82.81% 11 Missing ⚠️
core/ast/src/scope_analyzer.rs 0.00% 8 Missing ⚠️
core/engine/src/symbol.rs 0.00% 4 Missing ⚠️
core/parser/src/parser/statement/mod.rs 75.00% 4 Missing ⚠️
core/ast/src/declaration/variable.rs 75.00% 2 Missing ⚠️
core/ast/src/keyword/mod.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4649       +/-   ##
===========================================
+ Coverage   47.24%   59.12%   +11.87%     
===========================================
  Files         476      563       +87     
  Lines       46892    62531    +15639     
===========================================
+ Hits        22154    36970    +14816     
- Misses      24738    25561      +823     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

abhinavs1920 and others added 3 commits March 9, 2026 18:23
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
@jedel1043

Copy link
Copy Markdown
Member

Ping me after you fix the formatting so that I can merge this

abhinavs1920 and others added 2 commits March 13, 2026 15:46
abhinavs1920 and others added 2 commits March 13, 2026 20:43
Signed-off-by: Abhinav Sharma <abhinavs1920bpl@gmail.com>
@jedel1043
jedel1043 enabled auto-merge March 13, 2026 16:42
@jedel1043
jedel1043 added this pull request to the merge queue Mar 13, 2026
Merged via the queue into boa-dev:main with commit f5ae9f7 Mar 13, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Enhancement New feature or request C-AST Issue surrounding the abstract syntax tree C-Parser Issues surrounding the parser Waiting On Author Waiting on PR changes from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement explicit resource management proposal

3 participants