Skip to content

Default integer inference to native width - #9

Merged
miselin merged 1 commit into
mainfrom
codex/native-integer-inference
Aug 10, 2026
Merged

Default integer inference to native width#9
miselin merged 1 commit into
mainfrom
codex/native-integer-inference

Conversation

@miselin

@miselin miselin commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • default unconstrained integer literals to the target profile's signed native word width
  • range-check contextual integer literals at compile time without widening typed operands to fit literal values
  • promote compatible binary operands to a shared width for arithmetic and comparisons
  • apply the target C integer width to direct integer literals passed through varargs
  • require explicit casts for incompatible mixed-signedness operations

Why

Exact-width literal inference allowed values such as 0 and 1 to become i1. That could truncate inferred accumulators and make ordinary comparisons such as 1 < 2 behave incorrectly after lowering.

This keeps unconstrained literals ergonomic while preserving a systems-language boundary: i16_value + 70000 is a compile-time error rather than a value-driven implicit widening.

Validation

  • opam exec -- dune build
  • opam exec -- dune runtest
  • end-to-end compiled regression returned the expected result for inferred accumulation and comparison
  • git diff --check

The Nix CI gates were not run because nix is unavailable in the current environment. Repository-wide dune fmt is also blocked by pre-existing formatting drift; unrelated promoted formatting changes were reverted.

@miselin miselin added ai-generated This PR/code was majority generated by AI and may require deeper review. enhancement New feature or request labels Aug 10, 2026 — with ChatGPT Codex Connector
@miselin
miselin marked this pull request as ready for review August 10, 2026 04:24
@miselin
miselin merged commit 229a910 into main Aug 10, 2026
6 checks passed
@miselin
miselin deleted the codex/native-integer-inference branch August 10, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated This PR/code was majority generated by AI and may require deeper review. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant