pub(crate) fn coerce_user_fn_args(src: &str) -> StringExpand description
Collect every top-level user-defined function in src, then walk every
call site to those names and coerce mismatched arg types. MD2 author
sloppiness picked up here: passing lavcol(ret*2) where ret*2 is
vec3 but lavcol(float t) expects scalar (the EVET preset). HLSL
silently truncated; WGSL refuses with InvalidCall.
Coercion rules per arg:
- vec_n → f32: truncate via
.x(single-component swizzle). - f32 → vec_n: broadcast via
vec_n<f32>(arg). - vec_n → vec_m where n > m: truncate via
.xy/.xyz. - vec_n → vec_m where n < m: pad via
vec_m<f32>(arg, 0.0, …). - any other mismatch (Unknown, mat*, bool): pass through.
Conservative: only fires when the param type is a known scalar/vec and the inferred arg type is a known scalar/vec. Anything ambiguous stays untouched.