From 0fa687c764b9cffcf779955a52ca4407e013d46e Mon Sep 17 00:00:00 2001 From: Erik Carstensen Date: Wed, 28 May 2025 15:50:57 +0200 Subject: [PATCH] Don't crash on arrays of implement/interface objects --- py/dml/dmlparse.py | 6 +++++- test/1.4/errors/T_ESYNTAX.dml | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/py/dml/dmlparse.py b/py/dml/dmlparse.py index a580ae74..8b999f6d 100644 --- a/py/dml/dmlparse.py +++ b/py/dml/dmlparse.py @@ -474,7 +474,11 @@ def object3(t): | GROUP objident array_list maybe_istemplate object_spec | PORT objident array_list maybe_istemplate object_spec | IMPLEMENT objident array_list maybe_istemplate object_spec''' - t[0] = ast.object_(site(t), t[2], t[1], t[3], t[4] + t[5]) + array_spec = t[3] + if array_spec and t[1] in {'interface', 'implement'}: + report(ESYNTAX(site(t, 3), '[', f'array of {t[1]} not allowed')) + array_spec = [] + t[0] = ast.object_(site(t), t[2], t[1], array_spec, t[4] + t[5]) @prod_dml14 def object_subdevice(t): diff --git a/test/1.4/errors/T_ESYNTAX.dml b/test/1.4/errors/T_ESYNTAX.dml index 9290b7b7..8d930e03 100644 --- a/test/1.4/errors/T_ESYNTAX.dml +++ b/test/1.4/errors/T_ESYNTAX.dml @@ -86,6 +86,20 @@ if else { } +extern typedef struct { void (*f)(conf_object_t *); } foo_interface_t; + +implement foo +/// ERROR ESYNTAX + [ + i < 3] {} + +connect c { + interface foo + /// ERROR ESYNTAX + [ + i < 3]; +} + method init() { local int a; local int b;