Skip to main content

is_constant_expr

Function is_constant_expr 

Source
pub fn is_constant_expr(expr: &Expression<'_>) -> bool
Expand description

Determine if an expression is a compile-time constant. Used to decide whether a const variable gets a precise Zig type (Layer 1) or falls back to JsAny (Layer 3).

A constant expression is:

  • A literal (number, string, boolean, null, bigint)
  • A binary expression where both operands are constant
  • A unary expression where the argument is constant
  • A template literal with no interpolated expressions
  • An array where all elements are constant
  • An object where all property values are constant
  • A parenthesized expression wrapping a constant