robpike / ivy

ivy, an APL-like calculator
Other
1.33k stars 103 forks source link

ivy: fix nil panic on indexed assignment of rationals, floats or big ints #137

Closed fzipp closed 1 year ago

fzipp commented 1 year ago

Indexed assignment did not work for rationals, floats, and big integers because in the Copy methods of the types BigRat, BigFloat, and BigInt, relevant variables were not allocated before being used, leading to a nil panic. The following assignments now work:

x = iota 3
x[1] = 1/2
x[2] = float 0.5
x[3] = 10000000000