pub struct AbstractValue {
pub type_: Option<String>,
pub range_: Option<(Option<i64>, Option<i64>)>,
pub nullable: Nullability,
pub constant: Option<ConstantValue>,
}Expand description
Abstract representation of a variable’s value at a program point.
Tracks four dimensions:
type_: Inferred type (str, int, list, etc.) or None if unknownrange_: Value range [min, max] for numeric types, None for unboundednullable: Whether the value can be null/Noneconstant: If value is a known constant, the value itself
§Range Representation
The range_ field uses Option<(Option<i64>, Option<i64>)>:
Noneouter: No range information (unknown)Some((None, None)): Unbounded range (-inf, +inf)Some((Some(5), Some(5))): Exact value [5, 5]Some((Some(1), None)): Lower bound only [1, +inf)Some((None, Some(10))): Upper bound only (-inf, 10]
§JSON Infinity Representation (TIGER-PASS2-5)
In JSON output:
nullin range array position = infinity (unbounded)- Example:
"range": [null, 10]means (-inf, 10]
§TIGER-PASS1-11: Saturating Arithmetic
All arithmetic operations on ranges use saturating operations to prevent overflow. When overflow would occur, the bound is widened to infinity (None).
Fields§
§type_: Option<String>Inferred type name (e.g., “int”, “str”) or None if unknown
range_: Option<(Option<i64>, Option<i64>)>Value range [min, max] for numerics. None bounds mean infinity. For strings, tracks length.
nullable: NullabilityNullability status
constant: Option<ConstantValue>Known constant value (used for constant propagation)
Implementations§
Source§impl AbstractValue
impl AbstractValue
Sourcepub fn top() -> Self
pub fn top() -> Self
CAP-AI-04: Top of lattice - no information known (most permissive)
Returns an abstract value representing complete uncertainty:
- Unknown type
- Unknown range
- Maybe nullable
- No constant value
This is the default for variables with no information.
Sourcepub fn bottom() -> Self
pub fn bottom() -> Self
CAP-AI-04: Bottom of lattice - contradiction (unreachable code)
Returns an abstract value representing impossibility. Used for unreachable code paths.
Represented as:
- Type = “
” - Range = (None, None) - representing contradiction
- Nullable = Never (contradicts Always)
- No constant
Sourcepub fn from_constant(value: ConstantValue) -> Self
pub fn from_constant(value: ConstantValue) -> Self
CAP-AI-03: Create from known constant value
Creates an abstract value with precise information from a constant:
| Constant Type | type_ | range_ | nullable | constant |
|---|---|---|---|---|
| Int(v) | “int” | [v, v] | Never | Some(Int(v)) |
| Float(v) | “float” | None | Never | Some(Float(v)) |
| String(s) | “str” | [len, len] | Never | Some(String(s)) |
| Bool(v) | “bool” | [v as i64, v as i64] | Never | Some(Bool(v)) |
| Null | “NoneType” | None | Always | None |
§TIGER-PASS2-8: TypeScript undefined vs null
TypeScript undefined is tracked separately from null:
null-> type_ = “null”undefined-> type_ = “undefined”
Both have nullable = Always.
Sourcepub fn may_be_zero(&self) -> bool
pub fn may_be_zero(&self) -> bool
CAP-AI-05: Check if value could be zero (for division check)
Returns true if the range includes zero, indicating potential division-by-zero if used as a divisor.
§Logic
- Unknown range (None) -> true (conservative)
- Range [low, high] where low <= 0 <= high -> true
- Range [1, 10] -> false (excludes zero)
- Range [-10, -1] -> false (excludes zero)
Sourcepub fn may_be_null(&self) -> bool
pub fn may_be_null(&self) -> bool
CAP-AI-06: Check if value could be null/None
Returns true if the value might be null, indicating potential null dereference if used for attribute access.
§Logic
- Never -> false (safe to dereference)
- Maybe -> true (might be null)
- Always -> true (definitely null)
Sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Check if this is a known constant value
Returns true if the constant field is set.
Sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
Convert to JSON-serializable format
§JSON Format
{
"type": "int", // or null if unknown
"range": [5, 5], // [low, high], null = infinity
"nullable": "never", // "never" | "maybe" | "always"
"constant": 5 // only if known constant
}Trait Implementations§
Source§impl Clone for AbstractValue
impl Clone for AbstractValue
Source§fn clone(&self) -> AbstractValue
fn clone(&self) -> AbstractValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AbstractValue
impl Debug for AbstractValue
Source§impl Hash for AbstractValue
impl Hash for AbstractValue
Source§impl PartialEq for AbstractValue
impl PartialEq for AbstractValue
impl Eq for AbstractValue
Auto Trait Implementations§
impl Freeze for AbstractValue
impl RefUnwindSafe for AbstractValue
impl Send for AbstractValue
impl Sync for AbstractValue
impl Unpin for AbstractValue
impl UnsafeUnpin for AbstractValue
impl UnwindSafe for AbstractValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.