ponyc icon indicating copy to clipboard operation
ponyc copied to clipboard

Confusing compiler error when a field's field is assigned within a fun box

Open badcodecat opened this issue 2 years ago • 1 comments

when assigning to a variable in a class i recieved: not safe to write right side to left side which did not make it clear to me that i needed to use a fun ref. sample code to reproduce:

class TestClass
   var x: USize = 0

actor Main
  let my_test_class: TestClass = TestClass

  new create(env: Env) =>
    None
        
  fun test() =>
    my_test_class.x = 1

badcodecat avatar Jun 20 '22 16:06 badcodecat

There was an initial stab at fixing this that was later closed by the author but could serve as the basis for a fix. I don't know that it fixed the issue and didn't break other things but @KittenDeveloper stated that the it changed the error message. I don't know if it change unintended things as well.

https://github.com/ponylang/ponyc/pull/4147

SeanTAllen avatar Jun 21 '22 18:06 SeanTAllen