fastmail / Ix

automatic generation of JMAP-style APIs
GNU General Public License v2.0
10 stars 5 forks source link

do not promote null sort or filter to containers #55

Closed rjbs closed 7 years ago

rjbs commented 7 years ago

Right now, sort and filter might be autovivified from undef to [] and {} respectively. This preserves the original value.

If acting on the filters alters their contents rather than just promoting them, this is not enough, but we should be mapping new values into a new structure, not altering the input in place.

Tests for this are found in a downstream application.

wolfsage commented 7 years ago

+1.

Though, if we just dcloned the two arguments, wouldn't that be enough to protect us in all cases?

rjbs commented 7 years ago

Yeah, I tend to reach for dclone as a strategy of last resort because as I recall it's very slow. So, I considered this and decided against it, but it wasn't a very carefully considered thing, mostly habit.

rjbs commented 7 years ago

Applied.