microsoft / Power-Fx

Power Fx low-code programming language
MIT License
3.18k stars 321 forks source link

Deep mutations don't properly copy on write #2450

Closed gregli-msft closed 3 months ago

gregli-msft commented 3 months ago

Really deep mutations were not being properly copied on write, where t should be unaffected by the Patch:

>> Set( deep, [[[[1,2,3],[4,5,6]]]] )
deep: [[[[1, 2, 3], [4, 5, 6]]]]

>> Set( t, deep )
t: [[[[1, 2, 3], [4, 5, 6]]]]

>> Patch( First(First(First(deep).Value).Value).Value, {Value:2}, {Value:99} )
{Value:99}

>> deep
[[[[1, 99, 3], [4, 5, 6]]]]

>> t
[[[[1, 99, 3], [4, 5, 6]]]]
MikeStall commented 3 months ago

fixed