Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Parameters + Destructuring - Pending items #1641

Open
0xe opened this issue Sep 22, 2024 · 3 comments
Open

Default Parameters + Destructuring - Pending items #1641

0xe opened this issue Sep 22, 2024 · 3 comments
Labels
bug Issues considered a bug Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec

Comments

@0xe
Copy link
Contributor

0xe commented Sep 22, 2024

Address items pending from #1640

  • Destructuring with defaults in for loops. This should evaluate to 3, instead throws NPE:
function a() {}; (function() { 
            for (let {x = a()} = {}; ; ) { 
                return 3; 
            }
        })()
  • Reading [Symbol.iterator] from default array/object
function f([x = 1, y = 2] = {x: 3, y: 4}) {
 return x + y;
 }

This should throw a TypeError as [Symbol.iterator] is not implemented for that object on the rhs, instead uses defaults to return 3.

function f([x = 1, y = 2] = {x: 3, y: 4, 
                              [Symbol.iterator]: function*() { 
                                yield 3; 
                                yield 4; 
                              }}) {
                                return x + y;
                              }

And this should work because we call into iterator to get the default values. Instead we throw a NPE currently.

@p-bakker p-bakker added bug Issues considered a bug Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec labels Sep 24, 2024
@p-bakker
Copy link
Collaborator

@0xe any chance you'll be picking up this one not that the previous part has been merged?

@0xe
Copy link
Contributor Author

0xe commented Sep 26, 2024

@0xe any chance you'll be picking up this one not that the previous part has been merged?

Yep. I'm planning on starting with destructuring with defaults in for loops.

@0xe
Copy link
Contributor Author

0xe commented Oct 22, 2024

Looking to add support for destructuring with defaults in for loops, I found some problems in how default values were transformed. I've created a PR to fix those first: #1708.

gbrail pushed a commit that referenced this issue Oct 23, 2024
FIX: Transform default values correctly in destructuring

This addresses some of the issues in #1641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues considered a bug Ecma Incompatibility Issues about Rhino being incompatible with the EcmaScript spec
Projects
None yet
Development

No branches or pull requests

2 participants