Skip to content

Commit 59ac067

Browse files
committed
Evaluation.has_unknown
1 parent 719860a commit 59ac067

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/CallExpression.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @import { Context } from '../types' */
33
import { dev, is_ignored } from '../../../../state.js';
44
import * as b from '#compiler/builders';
5-
import { get_rune, UNKNOWN } from '../../../scope.js';
5+
import { get_rune } from '../../../scope.js';
66
import { transform_inspect_rune } from '../../utils.js';
77
import { should_proxy } from '../utils.js';
88

@@ -83,7 +83,7 @@ export function CallExpression(node, context) {
8383
node.callee.property.name
8484
) &&
8585
node.arguments.some(
86-
(arg) => arg.type === 'SpreadElement' || context.state.scope.evaluate(arg).values.has(UNKNOWN)
86+
(arg) => arg.type === 'SpreadElement' || context.state.scope.evaluate(arg).has_unknown
8787
)
8888
) {
8989
return b.call(

packages/svelte/src/compiler/phases/scope.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { is_reserved, is_rune } from '../../utils.js';
1616
import { determine_slot } from '../utils/slot.js';
1717
import { validate_identifier_name } from './2-analyze/visitors/shared/utils.js';
1818

19-
export const UNKNOWN = Symbol('unknown');
19+
const UNKNOWN = Symbol('unknown');
2020
/** Includes `BigInt` */
2121
const NUMBER = Symbol('number');
2222
const STRING = Symbol('string');
@@ -180,6 +180,13 @@ class Evaluation {
180180
*/
181181
is_known = true;
182182

183+
/**
184+
* True if the possible values contains `UNKNOWN`
185+
* @readonly
186+
* @type {boolean}
187+
*/
188+
has_unknown = false;
189+
183190
/**
184191
* True if the value is known to not be null/undefined
185192
* @readonly
@@ -540,6 +547,10 @@ class Evaluation {
540547
if (value == null || value === UNKNOWN) {
541548
this.is_defined = false;
542549
}
550+
551+
if (value === UNKNOWN) {
552+
this.has_unknown = true;
553+
}
543554
}
544555

545556
if (this.values.size > 1 || typeof this.value === 'symbol') {

0 commit comments

Comments
 (0)