nicopap / cuicui_layout

The dumbest and simplest layouting algorithm for bevy
40 stars 2 forks source link

Parser panic on some statements #102

Closed nicopap closed 1 year ago

nicopap commented 1 year ago

The following causes a panic when parsing as a .chirp file:

GameTab("Game Menu", 0)

error message:

panicked at chirp/src/parser/ast/build.rs:59:9:
2 - (StKind, SpawnHeader): Created header that never was initialized. This is a cuicui_chirp bug
0 - ChirpFileHeader: Created header that never was initialized.
nicopap commented 1 year ago

The issue is with the ? operator. In the parser, if there is any error, we abort all parsing. The issue is that:

  1. We push the header
  2. Gather header field values from parsing (which can early-return when parsing error)
  3. Initialize the header with the parsed values

This means in case of parse error, we do not initialize the header (which is fine, since we will never read it). But our drop-based trick doesn't know we don't read the AST in case of errors, it just knows the header was not initialized and panics.