ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.69k stars 410 forks source link

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

Open badcodecat opened 2 years ago

badcodecat commented 2 years ago

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
SeanTAllen commented 2 years ago

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