initiative-sh / initiative.sh

A web-based command line for game masters
https://initiative.sh/
GNU General Public License v3.0
44 stars 4 forks source link

Bug: Panic when creating a thing named "Journal" #327

Open MikkelPaulson opened 11 months ago

MikkelPaulson commented 11 months ago

Steps to reproduce:

  1. Open the web inspector it your browser.
  2. Type npc named journal.
  3. Press j.
  4. Bask in the error message panicked at 'internal error: entered unreachable code', core/src/storage/command.rs:367:30

The unreachable!() code should actually be unreachable - the problem is that the parse_input on line 352 is returning multiple results and the if let block is choosing the canonical StorageCommand::Journal result rather than the fuzzy StorageCommand::Load { .. } result, which is what we're actually concerned with at that point.

MikkelPaulson commented 11 months ago

@alfonsomartinezs If you're interested, this might help to your understanding of the nuances of command parsing.

ThinkerDreamer commented 3 weeks ago

After some experimentation with this in the browser, I discovered that after creating an NPC named "Journal", you can actually call your journal if you've already used the command, by pressing up and then enter. It's typing "j" in the box that causes the panic.

MikkelPaulson commented 3 weeks ago

Correct, the panic is in the autocomplete code, not the command parsing. Those are unfortunately two completely different code blocks that do effectively the same thing by way of incomplete vs. complete parsing (#104). Accessing it through the command history will bypass the autocomplete code altogether.