Skip to content

fix(warnings): reject unsafe short-circuit bindings - #61

Merged
mremond merged 7 commits into
mainfrom
fm/task-21440f13
Nov 16, 2026
Merged

mremond merged 7 commits into
mainfrom
fm/task-21440f13

Conversation

@mremond

@mremond mremond commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Why

A short-circuit right operand may not execute; unsafe names must be rejected without breaking valid inputs or formatting.

What changed

  • Report the originating andalso or orelse operator for unsafe right-only bindings.
  • Reject unsafe names consumed by patterns, chained operands and local sequences.
  • Preserve definite inputs and shadowing fun or comprehension bindings.
  • Preserve weak operand grouping when formatting binary expressions and flattened chains.

Before and after

Before: The two examples produced unbound errors, some unsafe consumers compiled, and formatting could remove required operand parentheses.

After: Both commands now identify unsafe operators across all 120 differential programs, and formatting preserves diagnostics and valid native execution.

This changes compiler text diagnostics, not an application view; command transcripts demonstrate the behavior.

Checked

Live validation: Demonstrated for this version. 4 of 4 scenarios driven live in the product.

Scenario Result Evidence
Unsafe right-only bindings ✅ Passed live Erlang, check and build rejected the generated cases with the expected originating operator.
Pattern and local-scope boundaries ✅ Passed live All 120 differential programs agreed: 74 rejections and 46 valid programs, including definite-input and shadowing controls.
Valid binding execution ✅ Passed live Native and BEAM each completed 16 assertions with identical output and zero exit.
Formatting preserves grouping and behavior ✅ Passed live Both unsafe fixtures remain idempotent with the expected diagnostics; the safe program completes 16 assertions natively and on BEAM after formatting.
  • Local build and checks: Strict lint, locked release build, allocator defaults/overrides and uncaught stacktrace order passed.
  • Rust workspace: 2,225 tests passed; one release-only measurement remained ignored.
  • Complete native suite: 523 tests passed; two fixtures requiring external modules remained skipped.
  • Regression stability: All 286 warnings tests, two compiler fixtures and two formatter tests passed in each of ten consecutive runs.
  • Formatter journey: Formatted fixtures retain their diagnostics; native and BEAM each complete 16 assertions before and after formatting.
  • Independent reviews: Code and all four behavior scenarios passed independent review.
How it was checked

Validated on macOS arm64 with Rust 1.99.0 and OTP 29.

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

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

cargo build --release --locked -j 2

python3 scripts/test-allocator-config.py

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

python3 scripts/test-stacktrace-order.py

Repeated ten times without retries: cargo test -p nera-ir --lib --locked -j 2 warnings::tests; cargo test -p nera-fmt --test binary_operand_grouping --locked -j 2; ./target/release/nera test '*unsafe_binding' -j 1.

The final formatter probe uses disposable in-place formatting and disk reads, avoiding the existing unchanged-stdout limitation.

The evidence retains unchanged comparisons and formatting checks. Local validation refreshed 24 comprehension cases and the runtime controls after the overlapping compiler update.

Risk

Risk above low: Blast radius, medium — Touches shared compiler diagnostics and the formatter binary-operand helper.; Novelty, medium — Extends existing recursive scope and reference analysis to more consumers.

Full risk assessment
Dimension Level Why
Blast radius medium Touches shared compiler diagnostics and the formatter binary-operand helper.
Behavior low Corrects invalid-program acceptance and unsafe-binding diagnostics.
Undo low Reverting the code restores the previous analyzer without data migration.
Evidence low Real check/build/OTP comparisons and native execution passed end to end.
Sensitivity low No sign-ins, keys, stored user data or release operations change.
Novelty medium Extends existing recursive scope and reference analysis to more consumers.
Dependencies low No dependencies are added or updated.

Pipeline

Updates from git push no-mistakes

Infinitary checked this version: an independent review that also judged the documents, and live validation the review accepted.

@github-actions github-actions Bot added this to the 0.1.1 milestone Nov 15, 2026
@mremond
mremond force-pushed the fm/task-21440f13 branch 2 times, most recently from af58465 to 32377b0 Compare November 15, 2026 20:46
@mremond
mremond merged commit cbcc1ce into main Nov 16, 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