Incorrect removal property from object accessed in nested conditions #3733
Closed
Description
opened on Nov 27, 2020
We have found a case where a property of a conditionally accessed object is incorrectly removed. This is a critical issue as it's impossible to lint for in a large code base and will fail at runtime.
tested versions:
20201126.0.0-nightly
20201102.0.0
source:
const X = {Y: 1};
function fn(a) {
if (a) {
return a ? X : {};
}
}
console.log(fn(true).Y);
java -jar compiler.jar -O ADVANCED --js test.js
output:
var a;a={};console.log(a.a);
expected output:
var a;a={a:1};console.log(a.a);
Notes:
Remove either of the conditions and it works as expected
Move the X variable declaration into fn
and it works as expected.
Inline the fn
and it works as expected.
Metadata
Assignees
Labels
No labels
Activity