goby-lang / goby

Goby - Yet another programming language written in Go
MIT License
3.49k stars 171 forks source link

Out of range error when two or more discontinued contents in Array #185

Closed hachi8833 closed 7 years ago

hachi8833 commented 7 years ago

The following works:

code = []
code[100] = 'Continue'
code[101] = 'Switching Protocols'
code[102] = 'Processing'

puts(code)

But the following causes panic on Goby while it works on Ruby:

code = []
code[100] = 'Continue'
code[101] = 'Switching Protocols'
code[102] = 'Processing'
code[200] = 'OK'

puts(code)

Looks like code[200] = 'OK' might be the cause: there are two empty index 0...99 and 103...199.

st0012 commented 7 years ago

@hachi8833 Thanks for reporting, this should be fixed in https://github.com/goby-lang/goby/commit/655515b288fa2fdb662c987e584de41cd9dd007a, please help me verify it.

hachi8833 commented 7 years ago

Confirmed the issue has been fixed on the master branch:

>> puts(code)
puts(code)
[nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "Continue", "Switching Protocols", "Processing", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, "OK"]
#=> nil

Thank you for the fix!