diff --git a/Cargo.toml b/Cargo.toml index 9fe463b1..b7ed71ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "customasm" -version = "0.13.1" +version = "0.13.2" edition = "2021" authors = ["hlorenzi "] description = "An assembler for custom, user-defined instruction sets!" diff --git a/src/asm/resolver/eval_asm.rs b/src/asm/resolver/eval_asm.rs index d980efab..d3873266 100644 --- a/src/asm/resolver/eval_asm.rs +++ b/src/asm/resolver/eval_asm.rs @@ -90,6 +90,10 @@ pub fn eval_asm( &encodings[0].1, (size, 0)); } + else if !ctx.can_guess() + { + return Err(()); + } } else diff --git a/src/asm/resolver/instruction.rs b/src/asm/resolver/instruction.rs index 3c7e725a..857a8432 100644 --- a/src/asm/resolver/instruction.rs +++ b/src/asm/resolver/instruction.rs @@ -439,6 +439,11 @@ fn resolve_instruction_match_inner( ctx, arg_eval_ctx)?; + if arg_value.should_propagate() + { + return Ok(arg_value); + } + let param = &rule.parameters[index]; eval_ctx.set_local( diff --git a/tests/expr_asm/err_multiple_matches.asm b/tests/expr_asm/err_multiple_matches.asm index 84664d36..cb7ee959 100644 --- a/tests/expr_asm/err_multiple_matches.asm +++ b/tests/expr_asm/err_multiple_matches.asm @@ -5,4 +5,4 @@ test {x} => asm { emit {x} } } -test 0x12 ; error: failed / note:_:5: within / error:_:5: multiple / note:_:3: match / note:_:4: match / error: did not converge \ No newline at end of file +test 0x12 ; error: failed / note:_:5: within / error:_:5: multiple / note:_:3: match / note:_:4: match \ No newline at end of file diff --git a/tests/issue169/err1.asm b/tests/issue169/err1.asm new file mode 100644 index 00000000..8aeb39d0 --- /dev/null +++ b/tests/issue169/err1.asm @@ -0,0 +1,16 @@ +#subruledef subtest +{ + {x: s32} => + { + assert(x > 0) + assert(x < 10) + x + } +} +#ruledef test +{ + test {s: s32} => s + testasm {a: subtest} => asm{test {a}} +} + +testasm 121 ; error: failed / note:_:13: within / note:_:3: within / error:_:6: assertion \ No newline at end of file diff --git a/tests/issue169/err2.asm b/tests/issue169/err2.asm new file mode 100644 index 00000000..b6a14f76 --- /dev/null +++ b/tests/issue169/err2.asm @@ -0,0 +1,24 @@ +#subruledef cpu6502_reladdr +{ + {addr: u16} => + { + reladdr = addr - $ - 2 + assert(reladdr <= 0x7f) + assert(reladdr >= !0x7f) + reladdr`8 + } +} + +#ruledef cpu6502 +{ + bcc {addr: cpu6502_reladdr} => 0x90 @ addr +} + +#ruledef cpu6502_macro +{ + bccmacro {addr: cpu6502_reladdr} => asm{bcc {addr}} +} + +bcc 120 +bccmacro 16384 ; error: failed / note:_:19: within / note:_:3: within / error:_:6: assertion +bcc 120 \ No newline at end of file