Skip to content

fix(ir): reject variables in record field defaults - #60

Merged
mremond merged 2 commits into
mainfrom
fm/task-3b8ec892
Nov 15, 2026
Merged

mremond merged 2 commits into
mainfrom
fm/task-3b8ec892

Conversation

@mremond

@mremond mremond commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Why

Record field defaults could bind variables even though Erlang rejects those definitions.

What changed

  • Check and build reject outer variables with a record-definition diagnostic.
  • Errors remain visible with warnings disabled, including unused or overridden defaults.
  • Legal fun locals, generator bindings and wildcard catches remain accepted.

Before and after

Before: Both compiler commands accepted an unused record default that bound and returned a variable.

After: All 24 invalid-default cases now fail as expected, and all eight wildcard-catch controls compile.

This changes compiler diagnostics rather than a graphical view; CLI transcripts verify the results.

Checked

Live validation: Awaiting live validation. This version and evidence need an independent review of coverage and proof.

  • Independent code review and conflict repair: Review cleared the approved implementation and proof. The repair retains that behavior and both changes' regression coverage.
How it was checked

cargo build --release --locked

cargo clippy --workspace --all-targets --locked -- -D warnings

cargo test --workspace --locked --no-fail-fast

./target/release/nera test -j 1 --timeout 30

python3 scripts/test-allocator-config.py; python3 scripts/test-stacktrace-order.py

Ten runs each: cargo test --locked -p nera-ir --lib warnings::tests; cargo test --locked -p nera --test record_default_variables

Local validation used macOS arm64. One Rust test was ignored and two external-dependency native cases were skipped.

Erlang rejects bare variable defaults as unbound; Nera uses the record-definition wording consistently for both invalid forms.

Risk

Risk above low: Blast radius, high — The shared variable analyzer runs for every checked module.

Full risk assessment
Dimension Level Why
Blast radius high The shared variable analyzer runs for every checked module.
Behavior low Invalid record defaults now fail compilation; legal defaults keep their behavior.
Undo low Reverting the commits restores the prior diagnostics.
Evidence low Real check/build transcripts, the full native suite and repeated tests passed.
Sensitivity low No saved data, sign-ins, signing material or release behavior changes.
Novelty low The existing variable walker gains record-default context.
Dependencies low No dependency changes.

@github-actions github-actions Bot added this to the 0.1.1 milestone Nov 15, 2026
@mremond
mremond merged commit fddb2dd into main Nov 15, 2026
21 checks passed
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.

1 participant