crystal-community / icr

Interactive console for Crystal programming language
MIT License
506 stars 40 forks source link

Error on exit/quit #124

Open LoadingBG opened 4 years ago

LoadingBG commented 4 years ago

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
jwoertink commented 4 years ago

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 😅

LoadingBG commented 4 years ago

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

Fryguy commented 2 years ago

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.