mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.18k stars 851 forks source link

FIX: Transform default values correctly in destructuring #1708

Closed 0xe closed 1 month ago

0xe commented 1 month ago

Default values for destructuring assignments weren't transformed correctly. Partially addresses #1641.

For example, all of these expressions with default values were not being evaluated correctly:

function a() { return 12;};  function b([x = a()] = []) { return x }; b()
function a() { return 12;};  function b([x = a()] = [1]) { return x }; b()
function a() { return 12;};  function b([x = 1] = [a()]) { return x }; b()
var a = { p1: { p2: 121}}; function b([x = a.p1.p2] = []) { return x }; b()
function a() { return 12;};  function b({x = a()} = {}) { return x }; b()
function a() { return 12;};  function b({x = a()} = {x: 1}) { return x }; b()
var a = { p1: { p2: 121}}; function b({x = a.p1.p2} = {}) { return x }; b()
function a() { return 12;};  function b({x = 1} = {x: a()}) { return x }; b()
rbri commented 1 month ago

the number of fixed tests is really impressive.good job.

gbrail commented 1 month ago

This is great -- thanks!