kaitai-io / kaitai_struct_webide

Online editor / visualizer for Kaitai Struct .ksy files
https://ide.kaitai.io
GNU General Public License v3.0
277 stars 62 forks source link

Silent error with no feedback #182

Open mckeed opened 1 month ago

mckeed commented 1 month ago

I hit a syntax error that kaitai-struct-compiler doesn't handle well. Here's a minimal example:

meta:
  id: test
  file-extension: test
seq:
  - id: test
    size: 0
instances:
  str:
    value: test.to_s() # illegal

The problem is the web IDE does not show an error message for this, so it's not obvious at first that something is wrong. If you already had a successful parse in the window, it looks like it's still working until you notice that nothing is updating any more. Very frustrating.

The js console shows

[Error] scala.scalajs.runtime.UndefinedBehaviorError: An undefined behavior was detected: undefined is not an instance of io.kaitai.struct.exprlang.Ast$expr

from raven.js. I can share a longer stack trace if that'd be helpful.

generalmimon commented 1 month ago

@mckeed Interesting, thanks for reporting. I've never seen this error, but it's apparently no longer reproducible at https://ide.kaitai.io/devel/ (which is the latest development version, see https://doc.kaitai.io/user_guide.html#web-ide), so I'm not sure this issue is directly actionable.

Perhaps we could look into how this situation happened with the stable Web IDE (or actually the stable KSC 0.10, because this is an error originating in the compiler) and verify that we don't have this problem anywhere else in the code. The Web IDE should also do a better job of handling even unexpected exceptions like this.