collect_bare_expr_stmt_edits

Function collect_bare_expr_stmt_edits 

Source
pub(crate) fn collect_bare_expr_stmt_edits(
    block: &Block,
    src: &str,
    edits: &mut Vec<TextEdit>,
)
Expand description

HLSL silently discards <expr>; statements that aren’t assignments or function calls — a typical typo for the user meaning expr = ... or expr += .... WGSL refuses with expected assignment or increment/decrement; found '-' (or *, etc.).

Corpus shapes (post-bb4754a 2000-sample, seed 42):

  • qrad-((rad-.5)/3)*(.2+.05*mid_att); — 10 presets sharing one warp shader (likely a missing = in the original author’s qrad-=...).
  • texsize.zw*r; — bare expression statement, 1 preset.
  • other <ident> <binop> <expr>; shapes in the long tail.

Wrap them as _ = <expr>; — WGSL’s phony assignment, which has the same “evaluate-and-discard” semantics HLSL took implicitly.