hdl.dsl: error on Elif immediately nested in an If.
I.e. on this code, which is currently not only wrongly accepted but also results in completely unexpected RTL: with m.If(...): with m.Elif(...): ... Fixes #500.
This commit is contained in:
parent
2c505deacc
commit
9d62cbefa5
|
@ -249,7 +249,7 @@ class Module(_ModuleBuilderRoot, Elaboratable):
|
|||
cond = self._check_signed_cond(cond)
|
||||
src_loc = tracer.get_src_loc(src_loc_at=1)
|
||||
if_data = self._get_ctrl("If")
|
||||
if if_data is None:
|
||||
if if_data is None or len(if_data["tests"]) == 0:
|
||||
raise SyntaxError("Elif without preceding If")
|
||||
try:
|
||||
_outer_case, self._statements = self._statements, []
|
||||
|
|
|
@ -266,6 +266,14 @@ class DSLTestCase(FHDLTestCase):
|
|||
with m.Elif(self.s2):
|
||||
pass
|
||||
|
||||
def test_Elif_wrong_nested(self):
|
||||
m = Module()
|
||||
with m.If(self.s1):
|
||||
with self.assertRaisesRegex(SyntaxError,
|
||||
r"^Elif without preceding If$"):
|
||||
with m.Elif(self.s2):
|
||||
pass
|
||||
|
||||
def test_Else_wrong(self):
|
||||
m = Module()
|
||||
with self.assertRaisesRegex(SyntaxError,
|
||||
|
|
Loading…
Reference in a new issue