Closed bwburnsides closed 9 months ago
The builtin assert now takes a string as an optional second argument. When present, it will be used as a custom error message if the condition fails.
assert
ex without custom message:
--> example.asm:10:1: 8 | } 9 | 10 | ld 0x70 ; error: failed / note:_:3: within / error:_:5: assertion | ^^^^^^^ 11 | + note: within `test`, rule 0 --> example.asm:3:5: 3 | ld {x} => | ^^^^^^ + error: assertion failed --> example.asm:5:9: 3 | ld {x} => 4 | { 5 | assert(x < 0x10) | ^^^^^^^^^^^^^^^^ 6 | 0x55 @ x`8 7 | }
ex with custom message:
--> example.asm:10:1: 8 | } 9 | 10 | ld 0x70 ; error: failed / note:_:3: within / error:_:5: assertion | ^^^^^^^ 11 | + note: within `test`, rule 0 --> example.asm:3:5: 3 | ld {x} => | ^^^^^^ + error: assertion failed: Your assertion has failed --> example.asm:5:9: 3 | ld {x} => 4 | { 5 | assert(x < 0x10, "Your assertion has failed") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 0x55 @ x`8 7 | }
The builtin
assert
now takes a string as an optional second argument. When present, it will be used as a custom error message if the condition fails.ex without custom message:
ex with custom message: