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:
whitequark 2020-10-22 13:23:06 +00:00
parent 2c505deacc
commit 9d62cbefa5
2 changed files with 9 additions and 1 deletions

View file

@ -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,