Assertion failure with *= operator
MortimerSnerd opened this issue · comments
Patrick Kelley commented
On commit ec7905e
For a class with user defined operator*
, the *= operator fails with the following assertion:
Assertion failed: false, file C:\src\lobster\dev\src\lobster\codegen.h, line 654
Writing it out as x = x * y works fine.
Repro code:
import vec
class mat3x4:
col0: xyzw_f
col1: xyzw_f
col2: xyzw_f
def operator*(o: mat3x4) -> mat3x4:
return mat3x4{
o.col0*col0.x + o.col1*col0.y + o.col2*col0.z + xyzw{0.0, 0.0, 0.0, col0.w},
o.col0*col1.x + o.col1*col1.y + o.col2*col1.z + xyzw{0.0, 0.0, 0.0, col1.w},
o.col0*col2.x + o.col1*col2.y + o.col2*col2.z + xyzw{0.0, 0.0, 0.0, col2.w}}
let ts = [mat3x4{xyzw_x, xyzw_y, xyzw_z}]
let xs = [mat3x4{xyzw_x, xyzw_y, xyzw_z}]
ts[0] *= xs[0]
// Following line works.
//ts[0] = ts[0] * xs[0]
Wouter van Oortmerssen commented
Thanks, fixed here: 91ee725
It does not automatically reuse *
for *=
, they need to be defined separately, such that *=
can actually overwrite the value rather than allocate a new one.