Skip to content

fix: enforce sized integer runtime bounds#15

Merged
vycdev merged 2 commits into
vycdev:mainfrom
vycdev2:fix/sized-integer-runtime-bounds
Jul 23, 2026
Merged

fix: enforce sized integer runtime bounds#15
vycdev merged 2 commits into
vycdev:mainfrom
vycdev2:fix/sized-integer-runtime-bounds

Conversation

@vycdev2

@vycdev2 vycdev2 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • enforce declared runtime ranges for int8/int16/int32 and uint8/uint16/uint32 after checked expressions and at typed interpreter boundaries
  • resolve primitive aliases before runtime normalization and report deterministic type-and-range diagnostics
  • add unit and end-to-end regression coverage for variable arithmetic, assignment, parameter, return, and nested-expression contexts
  • document the tree-walking interpreter contract in the design and architecture notes

Verification

  • cargo build — passed
  • cargo test -q — passed
  • cargo fmt --check — passed
  • cargo run -q -p jett_cli -- format --check tests/runtime_fail/<fixture>.jett (all six fixtures) — passed
  • git diff --check — passed

Risk

  • Low: the change is limited to interpreter normalization for fixed-width primitive integer carriers; full-range uint64 behavior remains on its existing path.

Closes #10

This was generated by an AI agent (vycdev2). Please verify any changes before merging or applying.

@vycdev vycdev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two runtime paths still miss the acceptance criteria:

  1. secret[T] preserves the underlying numeric type in the typechecker, but normalization only recognizes a bare primitive or an alias. A checked expression is recorded as secret[uint8], while typed-boundary type_expr_name collapses the generic to secret, so secret[uint8] maximum = 255; secret[uint8] one = 1; secret[uint8] overflow = maximum + one reaches 256 without this range check. Please unwrap the secret qualifier (including aliases whose base is secret-wrapped) and add an end-to-end regression.

  2. uint32 still uses Value::Int64, and eval_binary_op performs checked i64 arithmetic before expression normalization. For example, 4294967295 * 4294967295 fails as integer overflow: ... before normalize_sized_integer runs. Issue #10 explicitly requires deterministic diagnostics identifying the affected primitive type and operation or boundary. Please cover this path with a uint32 multiplication regression and retain uint32 in the diagnostic.

I could not run the Rust suite in this review environment because Cargo is unavailable; these findings follow directly from the type-name and evaluation paths.

value: Value,
) -> Result<Value, String> {
match type_name {
let primitive_type_name = self.primitive_base_type_name(type_name);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only resolves aliases to a bare name. It never unwraps secret[...]: checked expression metadata uses names such as secret[uint8], and type_expr_name returns just secret for a generic type at typed boundaries. Consequently secret-tainted sized arithmetic can still escape its underlying primitive range. Please normalize through the secret qualifier and test an overflowing secret[uint8] expression.

@vycdev2

vycdev2 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the requested runtime paths in commit 9e3eca5:

  • unwrap secret[T] and aliases whose base is secret-wrapped before fixed-width normalization;
  • retain the checked uint32 type, operation, and range when host i64 multiplication overflows;
  • add end-to-end regressions for direct/aliased secret[uint8] overflow and uint32 multiplication overflow.

Verification:

  • cargo build — passed
  • cargo test -q — passed
  • cargo fmt --check — passed
  • Jett formatter checks for all three new fixtures — passed
  • git diff --check — passed

This was generated by an AI agent (vycdev2). Please verify any changes before merging or applying.

@vycdev
vycdev merged commit a78c32d into vycdev:main Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: enforce runtime bounds for sized integer expressions

2 participants