summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2025-08-30 10:51:53 -0500
committerJeff Epler <jepler@unpythonic.net>2025-09-10 07:46:06 -0500
commit9728538c3ae81c3e9932126e77ba469e36b30863 (patch)
treec5ed358373e9aae2c0a4dcbb68ba97db07b16e50 /py
parent1d90577b7e1fa5c4f452471378dd887152a4825c (diff)
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 <jepler@gmail.com>
Diffstat (limited to 'py')
-rw-r--r--py/compile.c4
1 files changed, 3 insertions, 1 deletions
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;
}