icr icon indicating copy to clipboard operation
icr copied to clipboard

Error on exit/quit

Open LoadingBG opened this issue 4 years ago • 3 comments

When leaving the REPL using exit, I get an error:

Unhandled exception: Index out of bounds (IndexError)
  from ../../snap/crystal/397/share/crystal/src/indexable.cr:589:8 in '[]'
  from icr/src/icr/executer.cr:29:25 in 'execute'
  from icr/src/icr/console.cr:162:7 in 'execute'
  from icr/src/icr/console.cr:130:9 in 'process_result'
  from icr/src/icr/console.cr:122:7 in 'process_command'
  from icr/src/icr/console.cr:88:9 in 'process_input'
  from icr/src/icr/console.cr:66:12 in 'start'
  from icr/src/icr/cli.cr:126:1 in '__crystal_main'
  from ../../snap/crystal/397/share/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from ../../snap/crystal/397/share/crystal/src/crystal/main.cr:91:7 in 'main'
  from ../../snap/crystal/397/share/crystal/src/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???

and with quit:

Showing last frame. Use --error-trace for full trace.

In .icr_UwArnFrEUpNPonR2lwJ0uQ.cr:2:3

 2 | quit
     ^---
icr(0.35.1) > ed local variable or method 'quit' for top-level

LoadingBG avatar Nov 13 '20 17:11 LoadingBG

If you're building against master, we've renamed that command to #quit https://github.com/crystal-community/icr/pull/119/files Though it's not standard with most REPLs, the idea being that with how ICR works, "magic commands" would conflict with variables or methods being defined. We also have a PR to add in #help. I guess the README needs some updating 😅

jwoertink avatar Nov 13 '20 17:11 jwoertink

I read what was in the README.md file. Using # before the keyword seems to work. Maybe update the README.md then?

LoadingBG avatar Nov 14 '20 20:11 LoadingBG

This seems to be still happening since at least crystal 1.2.1. I'm not using master; I'm using the distribution from homebrew, which is 0.9.0.

Coming from Ruby, exit is the expected command, so IMO, that one should at least not blow up.

Fryguy avatar Jan 07 '22 14:01 Fryguy