irx.analysis.numeric_literals
irx.analysis.numeric_literals
Source: packages/irx/src/irx/analysis/numeric_literals.py
title: Contextual numeric literals and constant representability.Functions
default_numeric_literal_type(node: astx.LiteralInteger | astx.LiteralFloat) -> astx.DataType
title: >-
Select the uncontextualized source default without checking its value.
summary: >-
Contextual typing and representability remain semantic responsibilities.
parameters:
node:
type: astx.LiteralInteger | astx.LiteralFloat
returns:
type: astx.DataTypecontextualize_literal(value: astx.AST | None, target: astx.DataType | None) -> None
title: >-
Record expected types for exact literals, never for typed computations.
parameters:
value:
type: astx.AST | None
target:
type: astx.DataType | Noneliteral_semantic(node: astx.AST) -> SemanticInfo
title: Obtain a literal's semantic sidecar without modifying its payload.
parameters:
node:
type: astx.AST
returns:
type: SemanticInforesolve_numeric_literal(node: astx.AST, diagnostics: DiagnosticBag) -> astx.DataType | None
title: Resolve exact or explicitly typed literals into semantic metadata.
summary: >-
Consume any expected type for this visit; stale prior resolutions never
determine a context-typed literal's default. Preserve original values and
declared types, including explicitly typed floating payloads.
parameters:
node:
type: astx.AST
diagnostics:
type: DiagnosticBag
returns:
type: astx.DataType | Nonenumeric_constant(node: astx.AST) -> int | float | None
title: Read an already analyzed constant without evaluating user functions.
parameters:
node:
type: astx.AST
returns:
type: int | float | Noneanalyze_constant_operation(node: astx.BinaryOp | astx.UnaryOp, context: SemanticContext, result_type: astx.DataType | None) -> None
title: >-
Diagnose evaluated literal integer operations with exact host integers.
parameters:
node:
type: astx.BinaryOp | astx.UnaryOp
context:
type: SemanticContext
result_type:
type: astx.DataType | Noneanalyze_constant_cast(node: astx.Cast, context: SemanticContext) -> None
title: Check constant conversions using the same truncated integer domains.
parameters:
node:
type: astx.Cast
context:
type: SemanticContext