Fix delete with optional chaining not actually deleting properties#4720
Open
Ansh-699 wants to merge 3 commits intoboa-dev:mainfrom
Open
Fix delete with optional chaining not actually deleting properties#4720Ansh-699 wants to merge 3 commits intoboa-dev:mainfrom
delete with optional chaining not actually deleting properties#4720Ansh-699 wants to merge 3 commits intoboa-dev:mainfrom
Conversation
The `delete` operator with optional chaining (`?.`) was returning `true` but not actually deleting the property. This happened because `Access::from_expression()` has no arm for `Expression::Optional`, causing the compiler to fall through to the else branch that just evaluates the expression and pushes `true`. Added a new `compile_optional_delete` method that walks the optional chain, compiling intermediate accesses normally but emitting `DeletePropertyByName` or `DeletePropertyByValue` for the final chain item. Closes boa-dev#4719
Test262 conformance changes
Fixed tests (1):Broken tests (8): |
nekevss
requested changes
Feb 26, 2026
Member
nekevss
left a comment
There was a problem hiding this comment.
This is looking pretty good overall.
Can there be a few unit tests added to test the behavior of this PR.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4720 +/- ##
===========================================
+ Coverage 47.24% 57.24% +10.00%
===========================================
Files 476 552 +76
Lines 46892 60549 +13657
===========================================
+ Hits 22154 34662 +12508
- Misses 24738 25887 +1149 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
okie i'll add in a bit |
jedel1043
reviewed
Feb 27, 2026
Member
There was a problem hiding this comment.
Tests look kinda good, but instead of asserting that the value is undefined I'd use Object.getOwnPropertyDescriptor to assert that the descriptor itself gets deleted. This ensures we're properly checking deletion.
Assert that the property descriptor is fully removed rather than just checking for undefined, as suggested in review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
deletewith optional chaining (?.) returnedtruebut did not actually delete the property.Root Cause
Access::from_expression()has no arm forExpression::Optional, so the delete compilation falls to the else branch that just evaluates the expression and pushestruewithout emitting a delete opcode.Fix
Added
compile_optional_deleteandcompile_optional_delete_finalmethods in the bytecompiler (mod.rs). These walk the optional chain, compile intermediate accesses normally, and emitDeletePropertyByName/DeletePropertyByValuefor the final chain item. A newExpression::Optionalcheck inunary.rsroutes delete compilation through this path.Example (before fix)
Example (after fix)
Closes #4719