mirror of
https://github.com/hanzoai/babel.git
synced 2026-10-30 14:46:06 +00:00
* fix: Preserve computed key evaluation order in nested object rest (#17274) * fix: use inline memoization for computed keys to preserve eval order * test: use distinct values to properly validate computed key ordering fix * docs: update comments to reflect inline memoization approach * refactor: remove redundant state flags and AST mutations * fix: only memoize computed keys when rest elements are present * refactor: address review feedback
23 lines
548 B
JavaScript
23 lines
548 B
JavaScript
var _log, _log2, _log3, _log4;
|
|
// Computed keys must be evaluated in source order (left-to-right)
|
|
// even when nested object rest is involved. This test verifies
|
|
// that log(0), log(1), log(2), log(3) execute in that order.
|
|
|
|
function log(n) {
|
|
console.log(n);
|
|
return "x";
|
|
}
|
|
const _x = {
|
|
x: {
|
|
x: {}
|
|
}
|
|
},
|
|
{
|
|
[_log = log(0)]: {
|
|
[_log2 = log(1)]: x,
|
|
[_log3 = log(2)]: y
|
|
},
|
|
[_log4 = log(3)]: z
|
|
} = _x,
|
|
rest = babelHelpers.objectWithoutProperties(_x[_log], [_log2, _log3].map(babelHelpers.toPropertyKey));
|