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.
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, []
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,