gbdev / rgbds-obj

A Rust crate for working with RGBDS object files
MIT License
1 stars 1 forks source link

Infix printing panics #4

Closed Rangi42 closed 2 months ago

Rangi42 commented 2 months ago

This was using rgbobj with my local copy of rgbds-obj, since master is one commit past the latest release.

$ cat foo.asm
SECTION "test", ROM0
    ldh a, [hSPBuffer + 1]
$ ./target/debug/rgbobj -A foo.o
foo.o [118 bytes]:  RGBDS object v9 revision 9
Symbols: 1    Sections: 1    Assertions: 0

Symbols
-------

hSPBuffer [import]

Sections
--------

SECTION "test", ROM0
    $0002 (2) bytes:
    0000: f000

    1 patch:
    foo.asm(2) @ $0001 (byte)
        PC in "test" @ $0000
        RPN expression:
            Sym#0 $0001 + HRAM?
        RPN data (12 bytes):
            [81 00 00 00 00 80 01 00 00 00 00 60]
$ RUST_BACKTRACE=1 ./target/debug/rgbobj -A -r infix foo.o >/dev/null
thread 'main' panicked at /home/rangi/Desktop/rgbds-obj/src/rpn.rs:427:36:
internal error: entered unreachable code
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:145:5
   3: rgbds_obj::rpn::RpnOp::precedence
             at /home/rangi/Desktop/rgbds-obj/src/rpn.rs:427:36
   4: rgbds_obj::rpn::RpnOp::needs_parens
             at /home/rangi/Desktop/rgbds-obj/src/rpn.rs:462:23
   5: rgbds_obj::rpn::write_node::{{closure}}
             at /home/rangi/Desktop/rgbds-obj/src/rpn.rs:543:28
   6: rgbds_obj::rpn::write_node
             at /home/rangi/Desktop/rgbds-obj/src/rpn.rs:562:17
   7: rgbds_obj::rpn::RpnExpr::fmt_infix
             at /home/rangi/Desktop/rgbds-obj/src/rpn.rs:267:9
   8: <rgbds_obj::rpn::RpnExpr as core::fmt::Display>::fmt
             at /home/rangi/Desktop/rgbds-obj/src/rpn.rs:273:13
   9: <&T as core::fmt::Display>::fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/mod.rs:2333:62
  10: core::fmt::rt::Argument::fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/rt.rs:142:9
  11: core::fmt::run
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/mod.rs:1201:5
  12: core::fmt::write
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/mod.rs:1169:26
  13: std::io::Write::write_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/io/mod.rs:1843:15
  14: rgbobj::work
             at ./src/main.rs:568:37
  15: rgbobj::main
             at ./src/main.rs:21:23
  16: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
ISSOtm commented 2 months ago

Fixed by 7c64913!