Documentation
¶
Overview ¶
Package numconst handles numeric constant analysis for type inference.
This package determines precise numeric types for constant expressions, distinguishing between integers and floats where relevant.
Numeric Precision ¶
The package tracks:
- Integer constants: 1, 42, -100
- Float constants: 1.5, 3.14, -0.001
- Integer-valued floats: 1.0, 42.0
Type Refinement ¶
When a numeric literal appears in a context expecting a specific type, the package validates compatibility:
local x: integer = 42 -- valid local y: integer = 1.5 -- error: float assigned to integer
Integration ¶
Numeric constant analysis supports the constraint solver in making precise decisions about numeric type compatibility.
Index ¶
- func IntConstFromExpr(expr ast.Expr) (int64, bool)
- func NegateConstraints(items []constraint.Constraint) []constraint.Constraint
- func NegateNumericConstraint(c constraint.NumericConstraint) constraint.NumericConstraint
- func NumericConstraintFromComparisonWithBindings(op string, lhs, rhs ast.Expr, p cfg.Point, inputs *flow.Inputs, ...) constraint.NumericConstraint
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IntConstFromExpr ¶
IntConstFromExpr extracts an integer constant from an expression.
func NegateConstraints ¶
func NegateConstraints(items []constraint.Constraint) []constraint.Constraint
NegateConstraints negates a slice of constraints.
func NegateNumericConstraint ¶
func NegateNumericConstraint(c constraint.NumericConstraint) constraint.NumericConstraint
NegateNumericConstraint returns the negation of a numeric constraint.
func NumericConstraintFromComparisonWithBindings ¶
func NumericConstraintFromComparisonWithBindings(op string, lhs, rhs ast.Expr, p cfg.Point, inputs *flow.Inputs, bindings *bind.BindingTable) constraint.NumericConstraint
NumericConstraintFromComparisonWithBindings extracts a numeric constraint from a comparison using bindings.
Types ¶
This section is empty.