Skip to content

Fix frontend contracts and native regression tests - #723

Merged
LunaStev merged 8 commits into
wavefnd:masterfrom
LunaStev:fix/alpha-frontend-phase1
Sep 25, 2026
Merged

LunaStev merged 8 commits into
wavefnd:masterfrom
LunaStev:fix/alpha-frontend-phase1

Conversation

@LunaStev

@LunaStev LunaStev commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix frontend contracts that could change literal bytes, reject valid alias accesses, misreport source locations, or accept unsupported entry signatures. Correct native regression tests for Windows text output and Linux buffer source ranges.

  • Preserve exact \xNN bytes alongside UTF-8 source characters throughout lexing, parsing, and LLVM lowering. Reject embedded string NULs and validate literals used as text-only names or assembly.

  • Treat LF, CRLF, and standalone CR as one logical newline, including comments, target preprocessing, and diagnostics.

  • Resolve aliases before validating array/pointer/record accesses, and reject every parameterized main, including defaulted parameters.

  • Contain canonical std imports within the std root and handle nested multiline comments after target attributes.

  • Return structured local-storage, match, and extern-type diagnostics. Add lexer, nested-type, human/JSON diagnostic, and O0/O2 execution regressions.

  • Match Windows CRLF output without normalizing the non-UTF-8 payload being tested. Replace the Linux amd64 buffer case's ambiguous one-past source with an invalid internal range and assert rejection preserves metadata and contents.

Motivation

Closes #599, closes #598, closes #452, closes #709, closes #644, closes #645.
Closes #394, closes #396, closes #425, closes #708.
Closes #388, closes #389, closes #390, closes #391, closes #392, closes #393.

The existing implementations and regression tests for #395, #397, #398, and #399 were also checked. Those four diagnostic migrations were already present on master; this PR does not claim to introduce them.

Target and compatibility impact

The maintainer-approved language rules are: hex escapes denote exact bytes, ordinary source characters retain UTF-8 encoding, embedded string NULs are errors, all three source newline forms are equivalent, and main accepts zero parameters. Ordinary helper-function default arguments remain supported.

Literal bytes are represented in the shared lexer/AST and consumed by LLVM lowering. No new runtime ABI, libc FFI, or toolchain selection policy is introduced. Compatibility-revision validation remains intact. Target-independent entry checks are covered for hosted, freestanding, and WASI compilation.

Validation

Rust checks used LLVM 21 at /usr/lib64/llvm21 and --jobs 2:

cargo fmt --all --check
cargo test --locked --workspace --all-targets --jobs 2
cargo test --locked --test codegen_regressions main_parameter_contract --jobs 2
cargo test --locked -p lexer --jobs 2
cargo clippy --locked --workspace --all-targets --jobs 2 -- -D warnings
RUSTDOCFLAGS="-D warnings" cargo doc --locked --workspace --no-deps --jobs 2
cargo build --locked --release --jobs 2
./tools/check_std_policy.sh
python3 -m unittest tools.test_case_manifest tools.test_test_contracts tools.test_process_tree
git diff --check
  • The full default-feature workspace suite passed, including 97 codegen tests. The additional hosted/freestanding/WASI entry regression passed separately after it was added.
  • python3 tools/check_wave_corpus.py --wavec target/release/wavec --run-std-examples: 288 source checks passed. All 26 std examples passed after rerunning the seven socket-dependent binaries outside the network-restricted sandbox. The existing async TCP test likewise passed with local sockets permitted.
  • New shared cases test137 and test138 passed at O0/O2 under AArch64, RISC-V, and LoongArch QEMU, plus WASM32, WASM64, and WASI runners: 24 executions. Native O0/O2 tests also verify imported aliases, emitted bytes, and exact non-UTF-8 output.
  • Python tooling tests passed with one platform-specific skip; Python syntax checks passed.

Additional validation for the native regression fixes:

  • cargo test --locked --test codegen_regressions phase1_literal_printing_preserves_non_utf8_bytes --jobs 2: passed locally at O0/O2. The Windows expectation now matches the CRLF bytes in the failed native CI log; Windows execution remains for CI to verify.
  • cargo test --locked --test boundary_regressions linux_buffer_case_preserves_invalid_range_state_and_success_exit --jobs 2: the complete Linux amd64 test23.wave passed with exit 42 at O0/O2, using the matching staged std. The case checks unchanged pointer, length, capacity, and contents after rejecting the invalid range.
  • cargo test --locked --test boundary_regressions buffer_append_handles_adjacent_allocations_and_moving_self_sources --jobs 2: passed at O0/O2, retaining Do not classify an adjacent allocation as an internal buffer_append source #676 coverage for valid adjacent allocations and moving self-appends.
  • Targeted Clippy with -D warnings, formatting, std policy, and whitespace checks passed. The half-open allocation check and case success-exit contract remain unchanged.

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/.

Keep hex escapes as bytes, reject embedded string NULs, and preserve UTF-8 source text. Handle LF, CRLF, and CR consistently. Validate text-only literal contexts and propagate extern type errors as structured diagnostics.

Refs wavefnd#388, wavefnd#389, wavefnd#390, wavefnd#391, wavefnd#392, wavefnd#425, wavefnd#598, wavefnd#599.

Signed-off-by: LunaStev <[email protected]>
Track nested comments after target attributes while preserving original line endings and offsets. Reject invalid std module paths and canonical targets outside the std root.

Refs wavefnd#598, wavefnd#644, wavefnd#645.

Signed-off-by: LunaStev <[email protected]>
Canonicalize array, pointer, and record aliases for reads, writes, dereferences, and member accesses without changing invalid-access diagnostics.

Refs wavefnd#709.

Signed-off-by: LunaStev <[email protected]>
Require zero entry-point parameters even when every parameter has a default value. Preserve default arguments on ordinary helper functions.

Refs wavefnd#452.

Signed-off-by: LunaStev <[email protected]>
Report local const/static declarations and malformed match patterns, arrows, and bodies through source-located parser errors instead of direct output.

Refs wavefnd#394, wavefnd#396.

Signed-off-by: LunaStev <[email protected]>
Exercise nested generic types, imported aliases, exact literal bytes, NUL rejection, and human/JSON diagnostics. Run O0/O2 cases and check entry signatures across hosted, freestanding, and WASI targets.

Refs wavefnd#393, wavefnd#394, wavefnd#396, wavefnd#425, wavefnd#452, wavefnd#598, wavefnd#599, wavefnd#709.

Signed-off-by: LunaStev <[email protected]>
Preserve pointer, length, capacity, contents, and the exit-42 success contract when buffer_append rejects the range. Clarify external source validity and run the complete native case at O0/O2.

Fixes wavefnd#708.

Signed-off-by: LunaStev <[email protected]>
@LunaStev LunaStev changed the title Fix frontend literal, import, and semantic validation contracts Fix frontend contracts and native regression tests Sep 25, 2026
@LunaStev
LunaStev merged commit 5002a93 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