Closed makmic closed 7 months ago
I'm a bit hesitant. Unnecessary duping does cost performance (although not a lot); and the behavior is in line with for example "has_defaults".
Would it help if we printed a warning if you pass an unfrozen object to default:
?
Hi @kratob, being warned against this edge case would definitely be sufficient!
Went one step further and simply deprecated passing unfrozen objects, so you will get a warning. Released as 2.5.0.
I was recently surprised by some code like this :
It's quite clear that both
Frog
instances are sharing the same reference to an Array. active_type offers a solution to the problem ("usedefault: proc { [] }
") but I'd suggest to fix this specific use case in the library. Settingdefault: []
seems to work fine at first and can break apps in very unexpected ways much later on.Corresponding source code:
WDYT?