Skip to content

Matrix product causes 'Cannot apply the binary op to the arguments' shading parsing error #8790

@blazerzar

Description

@blazerzar

Description
Using matrix product with vectors or matrices causes WGSL shader parsing error 'Cannot apply the binary op to the arguments'.

Repro steps
In Firefox, open Matrix multiplication | Tour of WGSL. There will be a shader parsing error in the example shader. You can also take the shader

const m2x3 = mat2x3f(1, 2, 3, 4, 5, 6);
const mul_v3_by_m2x3 : vec2f = vec3(9, 8, 7) * m2x3;
const mul_m2x3_by_v2 : vec3f = m2x3 * vec2(9, 8);
const mul_m2x3_by_m4x2 : mat4x3f = m2x3 * mat4x2f(7, 8, 9, 10, 11, 12, 13, 14);

and try to compile it using naga. The same error is shown.

Expected vs observed behavior
The example on Tour of WGSL should work and the local shader should compile successfully since the matrices and vectors are of correct sizes, as described in Matrix arithmetic table in WGSL specification.

Extra materials
Naga error output:

Could not parse WGSL:
error: Cannot apply the binary op to the arguments
  ┌─ my_shader.wgsl:2:32
  │
2 │ const mul_v3_by_m2x3 : vec2f = vec3(9, 8, 7) * m2x3;
  │                                ^^^^^^^^^^^^^^^^^^^^ see msg

Platform
Tested using Firefox 146 (macOS 26 and Windows 11) and naga 28.0.0 (macOS 26).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions