`Evaluation.has_unknown`

pull/16515/head
ComputerGuy 1 month ago
parent 719860a27c
commit 59ac067068

@ -2,7 +2,7 @@
/** @import { Context } from '../types' */
import { dev, is_ignored } from '../../../../state.js';
import * as b from '#compiler/builders';
import { get_rune, UNKNOWN } from '../../../scope.js';
import { get_rune } from '../../../scope.js';
import { transform_inspect_rune } from '../../utils.js';
import { should_proxy } from '../utils.js';
@ -83,7 +83,7 @@ export function CallExpression(node, context) {
node.callee.property.name
) &&
node.arguments.some(
(arg) => arg.type === 'SpreadElement' || context.state.scope.evaluate(arg).values.has(UNKNOWN)
(arg) => arg.type === 'SpreadElement' || context.state.scope.evaluate(arg).has_unknown
)
) {
return b.call(

@ -16,7 +16,7 @@ import { is_reserved, is_rune } from '../../utils.js';
import { determine_slot } from '../utils/slot.js';
import { validate_identifier_name } from './2-analyze/visitors/shared/utils.js';
export const UNKNOWN = Symbol('unknown');
const UNKNOWN = Symbol('unknown');
/** Includes `BigInt` */
const NUMBER = Symbol('number');
const STRING = Symbol('string');
@ -180,6 +180,13 @@ class Evaluation {
*/
is_known = true;
/**
* True if the possible values contains `UNKNOWN`
* @readonly
* @type {boolean}
*/
has_unknown = false;
/**
* True if the value is known to not be null/undefined
* @readonly
@ -540,6 +547,10 @@ class Evaluation {
if (value == null || value === UNKNOWN) {
this.is_defined = false;
}
if (value === UNKNOWN) {
this.has_unknown = true;
}
}
if (this.values.size > 1 || typeof this.value === 'symbol') {

Loading…
Cancel
Save