Skip to content

Fix scalar I/O, constant lowering, and frontend contracts - #741

Merged
LunaStev merged 3 commits into
wavefnd:masterfrom
LunaStev:fix/frontend-io-and-constant-contracts
Sep 25, 2026
Merged

LunaStev merged 3 commits into
wavefnd:masterfrom
LunaStev:fix/frontend-io-and-constant-contracts

Conversation

@LunaStev

Copy link
Copy Markdown
Member

Summary

Fix incorrect scalar I/O, global constant conversions, integer matches, and method calls. For example, a u128 value above 64 bits now prints and reads exactly, and widening a u8 constant containing 255 to u64 preserves 255.

  • Share format parsing between the frontend and LLVM lowering. Preserve literal percent signs and unmatched braces; diagnose unknown or incompatible placeholders before code generation.
  • Preserve output signedness and support decimal input/output and hexadecimal output for all integer widths through 1024 bits. Check input ranges before storing, accept only numeric 0 and 1 for bool, and preserve neighboring fields and single evaluation of destination addresses.
  • Lower global character/string literals and numeric conversions using semantic types, including grouped/nested casts and aggregate initializers.
  • Range-check and deduplicate integer match patterns in the scrutinee type, carry exact values into typed HIR, and terminate merge blocks when every arm exits.
  • Materialize method default arguments and keep internal method symbols distinct from source function names.
  • Ignore target attributes inside ordinary comments. Preserve JSON UTF-8, decode Unicode escapes and surrogate pairs, and reject raw control bytes and nonfinite parsed numbers.

Motivation

Closes #724, closes #725, closes #726, closes #727, closes #728, closes #729.
Closes #733, closes #734, closes #735, closes #736, closes #737.
Closes #351, closes #539, closes #541.

Target and compatibility impact

Implements the approved format rules: unmatched braces are literal text, bool input accepts numeric 0/1, and existing integer widths through 1024 bits receive exact I/O support. Invalid integer input exits with status 1 before storing the invalid value. Balanced unsupported placeholders and untyped integer output literals outside the default i32 range produce frontend diagnostics.

Frontend validation and typed match values remain backend-independent. LLVM integer I/O reuses the existing printf/scanf runtime dependencies, uses width-exact conversion helpers, and avoids wide division libcalls. Method symbol changes are internal; no new public C ABI or toolchain selection policy is introduced. The std sources and compatibility revision are unchanged.

Validation

Rust checks used LLVM_SYS_211_PREFIX=/usr/lib64/llvm21 and --jobs 2:

cargo test --locked --workspace --jobs 2
cargo test --locked --jobs 2 --test frontend_regressions --test runtime_regressions --test std_io_regressions --test io_constant_regressions
cargo test --locked --jobs 2 --test std_io_regressions
cargo test --locked --jobs 2 --test io_constant_regressions
cargo test --locked --jobs 2 -p parser --test io_match_contracts
cargo clippy --locked --workspace --all-targets --jobs 2 -- -D warnings
cargo fmt --all -- --check
git diff --check
  • Workspace unit/parser tests and boundary regressions passed. Codegen regressions passed 97/98 in the restricted sandbox; the async TCP case passed separately with local sockets permitted. The executor restart runtime case and two std I/O TCP cases likewise passed outside the sandbox after socket/bind failures inside it. Remaining frontend/runtime/std I/O checks passed; these were targeted reruns, not a claimed clean unrestricted workspace invocation.
  • Seven new native execution regressions passed at O0/O2, including signed/unsigned boundaries for every integer width, long leading-zero inputs, invalid input, neighboring bool storage, literal bytes, global/runtime conversion parity, method defaults/collisions, and match control flow. Three new frontend regressions and JSON/comment unit regressions passed.
  • Integer I/O emitted LLVM IR and objects at O0/O2 for Windows x64/ARM64, Linux AArch64/RISC-V/LoongArch64, and wasm32/wasm64: 14 successful builds. These cross-target checks validate code generation, not execution on those targets.
  • Final Clippy, formatting, and whitespace checks passed.

Checklist

  • Commits include a DCO Signed-off-by line.
  • Tests cover new behavior or the PR explains why no test is needed.
  • User-facing changes include documentation or diagnostics updates.
  • The change preserves the license boundary between the compiler and std/.

@LunaStev
LunaStev merged commit cf485cf into wavefnd:master Sep 25, 2026
25 checks passed
@LunaStev LunaStev mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment