JohnEarnest/ok

bug with copy-on-write when a function fails

tangentstorm opened this issue · 0 comments

in iKe, while triggering the bug described in #96, there is a second bug that I noticed having to do with copy-on-write when i tried to make a backup of the original array that was being amended:

assert:{[err;t] $[&/t;1;err[]]}
isFlat:~|/0=@:'  / x contains no lists

a: 1 1 1 1
t: `
tick:{
  assert[`flat0; isFlat a]
  t::a  / `t` should be a copy of `a` *before* the assignment,
  / but if you inspect it, `t` is `a` *after* the following assignment:
  a[,1]::,0
  assert[`flat1; isFlat a]}

draw:{}

Note that isFlat a fails on the second run, so the assignment t::a only executes once. (Either it is constructing a view (rather than doing a global assignment), or there is something wrong with copy-on-write.

The workaround was to say t::(),a instead.