numconst

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntConstFromExpr

func IntConstFromExpr(expr ast.Expr) (int64, bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL