Skip to content

feat: implement using/await using declarations with SuppressedError#5130

Closed
xcb3d wants to merge 1 commit intoboa-dev:mainfrom
xcb3d:feat/using-declarations
Closed

feat: implement using/await using declarations with SuppressedError#5130
xcb3d wants to merge 1 commit intoboa-dev:mainfrom
xcb3d:feat/using-declarations

Conversation

@xcb3d
Copy link
Contributor

@xcb3d xcb3d commented Mar 18, 2026

It changes the following:

  • Implement using and await using declaration parsing with proper guards for line terminators (using\nlet triggers ASI), bracket tokens (using[0] is element access), and for (using of of arr) disambiguation
  • Add SuppressedError built-in constructor (core/engine/src/builtins/error/suppressed.rs) with full prototype chain inheriting from Error, registered as a global binding
  • Add disposal VM opcodes (CreateDisposeCapability, AddDisposableResource, DisposeResources) implementing the spec's DisposeResources abstract operation with proper error chaining via SuppressedError
  • Fix DisposeResources to incorporate pending exception as the initial completion per spec, so body errors and disposal errors are properly combined in the SuppressedError chain
  • Add IterableLoopInitializer::Using variant for for-of loops with immutable binding semantics
  • Block using declarations in switch clause bodies and top-level scripts per spec early errors

- Add using/await using declaration parsing with proper ASI, line
  terminator, and bracket token guards
- Add IterableLoopInitializer::Using for for-of loops
- Implement SuppressedError built-in constructor per spec
- Add disposal opcodes: CreateDisposeCapability, AddDisposableResource,
  DisposeResources with spec-compliant error chaining
- Block using declarations in switch clauses and top-level scripts
@xcb3d xcb3d requested a review from a team as a code owner March 18, 2026 08:01
@github-actions github-actions bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 18, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 18, 2026
@github-actions github-actions bot added C-Parser Issues surrounding the parser C-Tests Issues and PRs related to the tests. C-Builtins PRs and Issues related to builtins/intrinsics C-VM Issues and PRs related to the Boa Virtual Machine. C-AST Issue surrounding the abstract syntax tree labels Mar 18, 2026
@github-actions
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,073 50,238 +165
Ignored 2,072 1,649 -423
Failed 818 1,076 +258
Panics 0 0 0
Conformance 94.54% 94.85% +0.31%
Fixed tests (172):
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/throw-return-getter.js (previously Ignored)
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/length.js (previously Ignored)
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/is-function.js (previously Ignored)
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/throw-rejected-return.js (previously Ignored)
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/return-val.js (previously Ignored)
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/name.js (previously Ignored)
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/invokes-return.js (previously Ignored)
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/throw-return.js (previously Ignored)
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/prop-desc.js (previously Ignored)
test/built-ins/Iterator/prototype/Symbol.dispose/length.js (previously Ignored)
test/built-ins/Iterator/prototype/Symbol.dispose/is-function.js (previously Ignored)
test/built-ins/Iterator/prototype/Symbol.dispose/return-val.js (previously Ignored)
test/built-ins/Iterator/prototype/Symbol.dispose/name.js (previously Ignored)
test/built-ins/Iterator/prototype/Symbol.dispose/invokes-return.js (previously Ignored)
test/built-ins/Iterator/prototype/Symbol.dispose/prop-desc.js (previously Ignored)
test/built-ins/Symbol/dispose/no-key.js (previously Ignored)
test/built-ins/Symbol/dispose/cross-realm.js (previously Ignored)
test/built-ins/Symbol/dispose/prop-desc.js (previously Ignored)
test/built-ins/Symbol/asyncDispose/no-key.js (previously Ignored)
test/built-ins/Symbol/asyncDispose/cross-realm.js (previously Ignored)
test/built-ins/Symbol/asyncDispose/prop-desc.js (previously Ignored)
test/built-ins/SuppressedError/length.js (previously Ignored)
test/built-ins/SuppressedError/newtarget-proto-custom.js (previously Ignored)
test/built-ins/SuppressedError/is-a-constructor.js (previously Ignored)
test/built-ins/SuppressedError/message-tostring-abrupt.js (previously Ignored)
test/built-ins/SuppressedError/message-method-prop-cast.js (previously Ignored)
test/built-ins/SuppressedError/newtarget-is-undefined.js (previously Ignored)
test/built-ins/SuppressedError/proto.js (previously Ignored)
test/built-ins/SuppressedError/name.js (previously Ignored)
test/built-ins/SuppressedError/newtarget-proto.js (previously Ignored)
test/built-ins/SuppressedError/proto-from-ctor-realm.js (previously Ignored)
test/built-ins/SuppressedError/message-tostring-abrupt-symbol.js (previously Ignored)
test/built-ins/SuppressedError/prop-desc.js (previously Ignored)
test/built-ins/SuppressedError/message-undefined-no-prop.js (previously Ignored)
test/built-ins/SuppressedError/newtarget-proto-fallback.js (previously Ignored)
test/built-ins/SuppressedError/message-method-prop.js (previously Ignored)
test/built-ins/SuppressedError/prototype/errors-absent-on-prototype.js (previously Ignored)
test/built-ins/SuppressedError/prototype/constructor.js (previously Ignored)
test/built-ins/SuppressedError/prototype/message.js (previously Ignored)
test/built-ins/SuppressedError/prototype/proto.js (previously Ignored)
test/built-ins/SuppressedError/prototype/name.js (previously Ignored)
test/built-ins/SuppressedError/prototype/prop-desc.js (previously Ignored)
test/language/statements/for-of/head-await-using-bound-names-in-stmt.js (previously Ignored)
test/language/statements/for-of/head-using-bound-names-let.js (previously Ignored)
test/language/statements/for-of/head-await-using-bound-names-let.js (previously Ignored)
test/language/statements/for-of/head-using-init.js (previously Ignored)
test/language/statements/for-of/head-using-bound-names-fordecl-tdz.js (previously Ignored)
test/language/statements/for-of/head-using-fresh-binding-per-iteration.js (previously Ignored)
test/language/statements/for-of/head-await-using-init.js (previously Ignored)
test/language/statements/for-of/head-using-bound-names-in-stmt.js (previously Ignored)
test/language/statements/using/block-local-closure-get-before-initialization.js (previously Ignored)
test/language/statements/using/puts-initializer-on-top-of-disposableresourcestack-subsequent-usings.js (previously Ignored)
test/language/statements/using/using-allows-null-initializer.js (previously Ignored)
test/language/statements/using/initializer-disposed-at-end-of-asyncgeneratorbody.js (previously Ignored)
test/language/statements/using/redeclaration-error-from-within-strict-mode-function-using.js (previously Ignored)
test/language/statements/using/static-init-await-binding-invalid.js (previously Ignored)
test/language/statements/using/fn-name-cover.js (previously Ignored)
test/language/statements/using/initializer-disposed-at-end-of-block.js (previously Ignored)
test/language/statements/using/fn-name-fn.js (previously Ignored)
test/language/statements/using/global-use-before-initialization-in-prior-statement.js (previously Ignored)
test/language/statements/using/throws-error-as-is-if-only-one-error-during-disposal.js (previously Ignored)
test/language/statements/using/fn-name-gen.js (previously Ignored)
test/language/statements/using/Symbol.dispose-getter.js (previously Ignored)
test/language/statements/using/block-local-use-before-initialization-in-declaration-statement.js (previously Ignored)
test/language/statements/using/throws-if-initializer-missing-Symbol.dispose.js (previously Ignored)
test/language/statements/using/function-local-closure-get-before-initialization.js (previously Ignored)
test/language/statements/using/initializer-disposed-if-subsequent-initializer-throws-in-forstatement-head.js (previously Ignored)
test/language/statements/using/initializer-disposed-at-end-of-asyncfunctionbody.js (previously Ignored)
test/language/statements/using/global-use-before-initialization-in-declaration-statement.js (previously Ignored)
test/language/statements/using/initializer-disposed-at-end-of-forstatement.js (previously Ignored)
test/language/statements/using/puts-initializer-on-top-of-disposableresourcestack-multiple-bindings.js (previously Ignored)
test/language/statements/using/fn-name-class.js (previously Ignored)
test/language/statements/using/initializer-disposed-if-subsequent-initializer-throws.js (previously Ignored)
test/language/statements/using/cptn-value.js (previously Ignored)
test/language/statements/using/initializer-disposed-at-end-of-functionbody.js (previously Ignored)
test/language/statements/using/throws-if-initializer-not-object.js (previously Ignored)
test/language/statements/using/Symbol.dispose-method-called-with-correct-this.js (previously Ignored)
test/language/statements/using/throws-suppressederror-if-multiple-errors-during-disposal.js (previously Ignored)
test/language/statements/using/using-allows-undefined-initializer.js (previously Ignored)
test/language/statements/using/static-init-await-binding-valid.js (previously Ignored)
test/language/statements/using/fn-name-arrow.js (previously Ignored)
test/language/statements/using/global-closure-get-before-initialization.js (previously Ignored)
test/language/statements/using/initializer-disposed-at-end-of-generatorbody.js (previously Ignored)
test/language/statements/using/function-local-use-before-initialization-in-prior-statement.js (previously Ignored)
test/language/statements/using/throws-if-initializer-Symbol.dispose-property-not-callable.js (previously Ignored)
test/language/statements/using/multiple-resources-disposed-in-reverse-order.js (previously Ignored)
test/language/statements/using/block-local-use-before-initialization-in-prior-statement.js (previously Ignored)
test/language/statements/using/function-local-use-before-initialization-in-declaration-statement.js (previously Ignored)
test/language/statements/using/throws-if-initializer-Symbol.dispose-property-is-undefined.js (previously Ignored)
test/language/statements/using/throws-if-initializer-Symbol.dispose-property-is-null.js (previously Ignored)
test/language/statements/using/gets-initializer-Symbol.dispose-property-once.js (previously Ignored)
test/language/statements/using/syntax/using.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-assignment-statement-body-for-of.js (previously Ignored)
test/language/statements/using/syntax/with-initializer-label-statement.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-objectbindingpattern-after-bindingidentifier.js (previously Ignored)
test/language/statements/using/syntax/using-allows-bindingidentifier.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-for-in.js (previously Ignored)
test/language/statements/using/syntax/with-initializer-if-expression-statement-else-statement.js (previously Ignored)
test/language/statements/using/syntax/using-outer-inner-using-bindings.js (previously Ignored)
test/language/statements/using/syntax/with-initializer-while-expression-statement.js (previously Ignored)
test/language/statements/using/syntax/with-initializer-case-expression-statement-list.js (previously Ignored)
test/language/statements/using/syntax/without-initializer-if-expression-statement-else-statement.js (previously Ignored)
test/language/statements/using/syntax/block-scope-syntax-using-declarations-mixed-with-without-initializer.js (previously Ignored)
test/language/statements/using/syntax/using-allows-multiple-bindings.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-assignment-next-expression-for.js (previously Ignored)
test/language/statements/using/syntax/with-initializer-default-statement-list.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-arraybindingpattern-after-bindingidentifier.js (previously Ignored)
test/language/statements/using/syntax/using-not-allowed-at-top-level-of-script.js (previously Ignored)
test/language/statements/using/syntax/without-initializer-while-expression-statement.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-switchstatement-defaultclause.js (previously Ignored)
test/language/statements/using/syntax/using-for-statement.js (previously Ignored)
test/language/statements/using/syntax/with-initializer-do-statement-while-expression.js (previously Ignored)
test/language/statements/using/syntax/with-initializer-for-statement.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-arraybindingpattern-does-not-break-element-access.js (previously Ignored)
test/language/statements/using/syntax/block-scope-syntax-using-declarations-without-initializer.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-arraybindingpattern.js (previously Ignored)
test/language/statements/using/syntax/using-declaring-let-split-across-two-lines.js (previously Ignored)
test/language/statements/using/syntax/with-initializer-if-expression-statement.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-objectbindingpattern.js (previously Ignored)
test/language/statements/using/syntax/using-allowed-at-top-level-of-module.js (previously Ignored)
test/language/statements/using/syntax/using-invalid-switchstatement-caseclause.js (previously Ignored)
test/language/statements/using/syntax/without-initializer-do-statement-while-expression.js (previously Ignored)
test/language/statements/using/syntax/using-not-allowed-at-top-level-of-eval.js (previously Ignored)
test/language/statements/using/syntax/using-for-using-of-of.js (previously Ignored)
test/language/statements/using/syntax/without-initializer-label-statement.js (previously Ignored)
test/language/statements/using/syntax/block-scope-syntax-using-declarations-mixed-without-with-initializer.js (previously Ignored)
test/language/statements/using/syntax/without-initializer-for-statement.js (previously Ignored)
test/language/statements/using/syntax/without-initializer-if-expression-statement.js (previously Ignored)
test/language/statements/for-await-of/head-using-init.js (previously Ignored)
test/language/statements/for-await-of/head-await-using-init.js (previously Ignored)
test/language/statements/await-using/global-use-before-initialization-in-prior-statement.js (previously Ignored)
test/language/statements/await-using/await-using-allows-undefined-initializer.js (previously Ignored)
test/language/statements/await-using/redeclaration-error-from-within-strict-mode-function-await-using.js (previously Ignored)
test/language/statements/await-using/function-local-use-before-initialization-in-prior-statement.js (previously Ignored)
test/language/statements/await-using/block-local-use-before-initialization-in-prior-statement.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-invalid-switchstatement-defaultclause.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-not-allowed-at-top-level-of-eval.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-invalid-objectbindingpattern-after-bindingidentifier.js (previously Ignored)
test/language/statements/await-using/syntax/with-initializer-label-statement.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-not-allowed-at-top-level-of-script.js (previously Ignored)
test/language/statements/await-using/syntax/with-initializer-if-expression-statement-else-statement.js (previously Ignored)
test/language/statements/await-using/syntax/with-initializer-while-expression-statement.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-declaring-let-split-across-two-lines.js (previously Ignored)
test/language/statements/await-using/syntax/with-initializer-case-expression-statement-list.js (previously Ignored)
test/language/statements/await-using/syntax/without-initializer-if-expression-statement-else-statement.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-invalid-objectbindingpattern.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-invalid-arraybindingpattern.js (previously Ignored)
test/language/statements/await-using/syntax/with-initializer-default-statement-list.js (previously Ignored)
test/language/statements/await-using/syntax/without-initializer-while-expression-statement.js (previously Ignored)
test/language/statements/await-using/syntax/with-initializer-do-statement-while-expression.js (previously Ignored)
test/language/statements/await-using/syntax/with-initializer-for-statement.js (previously Ignored)
test/language/statements/await-using/syntax/block-scope-syntax-await-using-declarations-without-initializer.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-invalid-switchstatement-caseclause.js (previously Ignored)
test/language/statements/await-using/syntax/with-initializer-if-expression-statement.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-invalid-for-in.js (previously Ignored)
test/language/statements/await-using/syntax/without-initializer-do-statement-while-expression.js (previously Ignored)
test/language/statements/await-using/syntax/without-initializer-label-statement.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-invalid-arraybindingpattern-does-not-break-element-access.js (previously Ignored)
test/language/statements/await-using/syntax/without-initializer-for-statement.js (previously Ignored)
test/language/statements/await-using/syntax/block-scope-syntax-await-using-declarations-mixed-with-without-initializer.js (previously Ignored)
test/language/statements/await-using/syntax/await-using-invalid-arraybindingpattern-after-bindingidentifier.js (previously Ignored)
test/language/statements/await-using/syntax/without-initializer-if-expression-statement.js (previously Ignored)
test/language/statements/await-using/syntax/block-scope-syntax-await-using-declarations-mixed-without-with-initializer.js (previously Ignored)
test/staging/explicit-resource-management/async-disposable-stack-adopt-on-disposed-stack.js (previously Ignored)
test/staging/explicit-resource-management/async-disposable-stack-disposed-getter.js (previously Ignored)
test/staging/explicit-resource-management/async-disposable-stack-move-on-disposed-stack.js (previously Ignored)
test/staging/explicit-resource-management/using-with-null-or-undefined.js (previously Ignored)
test/staging/explicit-resource-management/exception-handling.js (previously Ignored)
test/staging/explicit-resource-management/async-disposable-stack-defer-on-disposed-stack.js (previously Ignored)
test/staging/explicit-resource-management/async-disposable-stack-use-on-disposed-stack.js (previously Ignored)
test/staging/explicit-resource-management/Symbol/dispose/cross-realm.js (previously Ignored)
test/staging/explicit-resource-management/Symbol/dispose/prop-desc.js (previously Ignored)
Broken tests (7):
test/built-ins/Proxy/revocable/tco-fn-realm.js (previously Passed)
test/language/expressions/class/private-setter-brand-check-multiple-evaluations-of-class-realm.js (previously Passed)
test/language/expressions/class/private-getter-brand-check-multiple-evaluations-of-class-realm-function-ctor.js (previously Passed)
test/language/expressions/class/private-method-brand-check-multiple-evaluations-of-class-realm-function-ctor.js (previously Passed)
test/language/expressions/class/private-method-brand-check-multiple-evaluations-of-class-realm.js (previously Passed)
test/language/expressions/class/private-setter-brand-check-multiple-evaluations-of-class-realm-function-ctor.js (previously Passed)
test/language/expressions/class/private-getter-brand-check-multiple-evaluations-of-class-realm.js (previously Passed)

Tested main commit: 34b2b74b541a8d3a62a8775e696e920217756e71
Tested PR commit: bafd87e94b949e78a88e99d1f7e7db0b65658d51
Compare commits: 34b2b74...bafd87e

@xcb3d xcb3d marked this pull request as draft March 18, 2026 08:11
@jedel1043
Copy link
Member

Duplicate of #5079

@jedel1043 jedel1043 marked this as a duplicate of #5079 Mar 18, 2026
@jedel1043 jedel1043 closed this Mar 18, 2026
@github-actions github-actions bot removed the Waiting On Review Waiting on reviews from the maintainers label Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-AST Issue surrounding the abstract syntax tree C-Builtins PRs and Issues related to builtins/intrinsics C-Parser Issues surrounding the parser C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants