mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
refs https://forum.nim-lang.org/t/12785, refs #4711 The code was already there that when `propertyWriteAccess` returns `nil` (i.e. cannot find a setter), `semAsgn` turns the [LHS into a call and semchecks it](1ef9a656d2/compiler/semexprs.nim (L1941-L1948)), meaning if a setter cannot be found a getter will be assigned to instead. However `propertyWriteAccess` never returned nil, because `semOverloadedCallAnalyseEffects` was not called with `efNoUndeclared` and so produced an error directly. So `efNoUndeclared` is passed to this call so this code works as intended. This fixes the issue described in #4711 which was closed because subscripts do not have the same behavior implemented. However we can implement this for subscripts as well (I have an implementation ready), it just changes the error message from the failed overloads of `[]=` to the failed overloads of `[]` for the LHS, which might be misleading but is consistent with the error messages for any other assignment. I can do this in this PR or another one. (cherry picked from commit4d9e5e8b6d)