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 · 0 comments
Open

Default Parameters + Destructuring - Pending items #1641

0xe opened this issue Sep 22, 2024 · 0 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
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