[Issue 17474] non-property being treated as a property

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 9 23:11:59 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17474

--- Comment #6 from Tomer Filiba (weka) <tomer at weka.io> ---
(In reply to Walter Bright from comment #4)
> But I can suggest avoiding using default function arguments. Default
> arguments are a good solution for adding parameters without breaking
> existing code, but are not a good practice otherwise. 

that's exactly what happened -- i added this default parameter to an existing
function that did not have parameters, and it broke in a very peculiar way. i
ended up using

ref T _fiberLocal(T)(FiberLocalBlock* block) {...}
ref T fiberLocal(T)() {_fiberLocal!T(_currentFiberLocalBlock);}

again, i'm fine with this workaround, but unless our UTs caught that early on,
debugging it on a live system would have been impossible.

i agree with stefan that a function returning `ref` shouldn't be allowed in 
property-setter syntax. either it shouldn't be allowed at all, i.e., `foo =
bar` won't compile if foo returns `ref` and takes an argument -- or only allow
the lowering to `foo() = bar`

--


More information about the Digitalmars-d-bugs mailing list