Skip to content

Panic when enum is used before it's declared #153

@T3sT3ro

Description

@T3sT3ro

For the following:

little_endian_packets


packet TestPacket {
    a: 8,
    b: CoffeeAddition,
}

enum CoffeeAddition: 5 {
  Empty = 0,
  Other = ..
}

It fails with:

RUST_BACKTRACE=1 pdlc protocol.pdl

thread 'main' (179592) panicked at /.../.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pdl-compiler-0.4.4/src/analyzer.rs:493:23:
no entry found for key
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: pdl_compiler::analyzer::Schema::new
   4: pdl_compiler::analyzer::analyze
   5: pdlc::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

It would be useful to add a message about the order of identifiers, or better yet, allow for position independent declarations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions