hlorenzi / customasm

💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Apache License 2.0
719 stars 56 forks source link

Assembler terminates without error message #64

Closed pol-rivero closed 3 years ago

pol-rivero commented 3 years ago

I found a small bug on the latest version 0.11.3. Let's say I want to assemble the following code:

#subruledef REG {
    my_reg => 0xA
}
#ruledef {
    test {Addr: u16} => 0x1 @ Addr
    test {register: REG} + {Not_Imm: u16} => register`4 @ Imm
}

test my_reg + 1

Version 0.11.2 succesfully identifies that I was trying to use the second instruction (test {register: REG} + {Not_Imm: u16}), and that I had made a typo (I typed Not_Imm: u16 instead of Imm: u16). Therefore, it correcly displays the error message

error: unknown variable
test {register: REG} + {Not_Imm: u16} => register`4 @ Imm
                                                      ^^^

However, version 0.11.3 doesn't show any error message and just terminates with exit code 1. Its only output is

customasm v0.11.3 (2020-12-05, x86_64-pc-windows-gnu)
assembling `test.asm`...

Again, it's a pretty small bug that only happens on this edge case, but it's rather confusing to not have any indication on what went wrong, specially when assembling large files.

clubby789 commented 3 years ago

Tracked the problem down to https://github.com/hlorenzi/customasm/blob/030ed1031e5da8778464f299105573c2a32497ca/src/diagn/report.rs#L242-L249 The for loop isn't run at all. Printing the length of report.messages every time a new message is pushed outputs '1' several times, so somewhere the messages seem to be getting lost.