Skip to content

Reject mutations in condition expressions - #336

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
LunaStev:patch/condition-assignment-validation
Aug 11, 2026
Merged

Reject mutations in condition expressions#336
LunaStev merged 1 commit into
wavefnd:masterfrom
LunaStev:patch/condition-assignment-validation

Conversation

@LunaStev

Copy link
Copy Markdown
Member

Summary

  • reject assignments, compound assignments, and increment/decrement expressions inside if, else if, while, and for conditions
  • detect mutations even when they are nested inside grouped, binary, call, index, aggregate, or other expression forms
  • preserve ordinary assignment statements and for increment expressions
  • provide actionable diagnostics that distinguish comparison mistakes from intentional mutations

Root cause

Assignment expressions return the assigned value, and Wave permits scalar values such as char in truthy conditions. As a result, code such as if (command[0] = 'h') mutated the value and then entered the branch instead of being rejected as a likely comparison mistake.

Impact

Condition evaluation can no longer silently mutate program state through assignment-like expressions. Programs must perform mutations before the condition and use an explicit comparison or value test inside the condition.

Validation

  • cargo fmt --all --check
  • cargo test --locked --all-targets --verbose
  • cargo clippy --locked --all-targets -- -D warnings
  • manual wavec check reproduction for if (command[0] = 'h')

@LunaStev
LunaStev marked this pull request as ready for review August 11, 2026 11:36
@LunaStev
LunaStev merged commit 831d3ae into wavefnd:master Aug 11, 2026
4 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