Skip to content

Commit

Permalink
return UnknownValue if the usedbranch is unkown and the path is not e…
Browse files Browse the repository at this point in the history
…mpty (#5846)
  • Loading branch information
TrickyPi authored Feb 17, 2025
1 parent f9c52f8 commit ba692fe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast/nodes/LogicalExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable
if (usedBranch) {
this.expressionsToBeDeoptimized.push(origin);
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
} else if (!this.hasDeoptimizedCache) {
} else if (!this.hasDeoptimizedCache && !path.length) {
const rightValue = this.right.getLiteralValueAtPath(path, recursionTracker, origin);
const booleanOrUnknown = tryCastLiteralValueToBoolean(rightValue);
if (typeof booleanOrUnknown !== 'symbol') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = defineTest({
description: 'keep logical expressions'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const config = {
someComponent: { },
default: { config1: 'config1DefaultValue' }
};

var main = (config.someComponent || config.default).config1 || 'config1DefaultValue';

export { main as default };
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const config = {
someComponent: { someOtherConfig: false },
default: { config1: 'config1DefaultValue' }
};

export default (config.someComponent || config.default).config1 || 'config1DefaultValue';

0 comments on commit ba692fe

Please sign in to comment.