savi icon indicating copy to clipboard operation
savi copied to clipboard

A `let` property cannot be reassigned after all fields have been initialized

Open mneumann opened this issue 3 years ago • 4 comments

:struct A
  :let field U8: 5

  :new (@field)

I'd assume that it is possible assign a value to a let field in a constructor and if not, the :let declarators default value is taken.

mneumann avatar Sep 18 '22 15:09 mneumann

I agree this would be nice to have, but it will make the completeness analysis significantly more complicated, I think.

jemc avatar Sep 18 '22 17:09 jemc

I see. So we should better raise an error at compile time in these situation. IIRC, there is already an open issue for that.

mneumann avatar Sep 18 '22 17:09 mneumann

Sorry, mixing things up. Well, :let default values as of now are more or less constant as you cannot change them.

mneumann avatar Sep 18 '22 17:09 mneumann

Right, I agree it would be more useful if default values for :let could be overridden by explicit values in a constructor, and right now, that is not possible.

jemc avatar Sep 18 '22 17:09 jemc