From 9728538c3ae81c3e9932126e77ba469e36b30863 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 30 Aug 2025 10:51:53 -0500 Subject: py/compile: Throw SyntaxError instead of asserting. This condition corresponds to invalid asm code like ``` @micropython.asm_rv32 def l(): a=di(a2, a2, -1) ``` and possibly other forms where nodes[0] is not a STRUCT. Signed-off-by: Jeff Epler --- py/compile.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'py/compile.c') diff --git a/py/compile.c b/py/compile.c index 7a1151bcd..945ee2b2d 100644 --- a/py/compile.c +++ b/py/compile.c @@ -3277,7 +3277,9 @@ static void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind } // check structure of parse node - assert(MP_PARSE_NODE_IS_STRUCT(pns2->nodes[0])); + if (!MP_PARSE_NODE_IS_STRUCT(pns2->nodes[0])) { + goto not_an_instruction; + } if (!MP_PARSE_NODE_IS_NULL(pns2->nodes[1])) { goto not_an_instruction; } -- cgit v1.2.3