replace_statement_commas

Function replace_statement_commas 

Source
pub(crate) fn replace_statement_commas(src: &str) -> String
Expand description

HLSL allows comma-as-statement-separator at the top of a function body:

ret += saturate(...),
ret += saturate(...),
ret = lerp(ret, blurs, t);

WGSL requires ; between statements; a stray comma triggers expected ;, found ‘,’. At this point in the pipeline every multi- name vardeclaration has already been split into onevar per name (see [rewrite_local_declarations]), so a comma at paren/bracket- depth 0 is unambiguously a statement separator. Rewrite to ;`.

Comments are skipped so a , inside /* */ doesn’t confuse anyone.