Take_last bug? (no implicit conversion from nil to integer)

Hi All,

Running the following on Sonic PI 3.2.2 (Windows 10):

puts (ring 1, 2, 3, 4, 5, 6, 7).take_last(2)

Fails with error:

Runtime Error: [workspace_seven] - TypeError
Thread death!
 no implicit conversion from nil to integer
C:/apps/sonic-pi/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/core.rb:557:in `[]'
C:/apps/sonic-pi/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/core.rb:557:in `[]'
C:/apps/sonic-pi/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/core.rb:803:in `take_last'
workspace_seven:in `block (2 levels) in __spider_eval'
C:/apps/sonic-pi/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/lib/sonicpi/runtime.rb:781:in `eval'
C:/apps/sonic-pi/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/lib/sonicpi/runtime.rb:781:in `block (2 levels) in __spider_eval'
C:/apps/sonic-pi/Sonic Pi Portable/App/Sonic Pi/app/server/ruby/lib/sonicpi/runtime.rb:1042:in `block (2 levels) in __in_thread'

I tried similar code replacing take_last with drop_last, and it worked as expected. So is this a bug in take_last?

I just discovered Sonic Pi a few days back, so I may be missing something obvious.

Thanks in advance,
Ceredig

1 Like

Hello @Ceredig,

A fix for this was merged a little while ago and it is available now through the beta builds or compiling it yourself. Otherwise, it will be available in the next official release coming out some time hopefully early next year :slightly_smiling_face:

2 Likes

Hi @ethancrawford

Thank you for the quick response.