Skip to content

Add test case where PropertyBindingInitialization throws when _value_ is non-iterable#4916

Open
G-Lee1031 wants to merge 2 commits intotc39:mainfrom
G-Lee1031:propertybindinginitialization-non-iterable
Open

Add test case where PropertyBindingInitialization throws when _value_ is non-iterable#4916
G-Lee1031 wants to merge 2 commits intotc39:mainfrom
G-Lee1031:propertybindinginitialization-non-iterable

Conversation

@G-Lee1031
Copy link
Contributor

@G-Lee1031 G-Lee1031 commented Feb 10, 2026

Hello.
This PR adds a test case where PropertyBindingInitialization performed in two cases of BindingInitialization throws when value is non-iterable. I will address those two cases separately below.

Check 1 covers

ObjectBindingPattern: {BindingPropertyList} {BindingPropertyList, }. PropertyBindingInitializationis performed in step 1

Check 2 covers

ObjectBindingPattern: {BindingPropertyList, BindingRestProperty} PropertyBindingInitialization is performed in step 1.

In both cases, BindingPattern : ArrayBindingPattern is reached beacause of x: []. As a result, GetIterator(obj, kind) where obj is undefined is called. Getiterator calls GetMethod(obj, %Symbol.iterator%) in step 2, which calls ToObject(object). Because object is undefined, ToObject throws TypeError.

@G-Lee1031 G-Lee1031 requested a review from a team as a code owner February 10, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants