From: whitequark Date: Thu, 13 Jun 2019 03:56:49 +0000 (+0000) Subject: hdl.ast: tighten assertion in Switch(). X-Git-Tag: locally_working~164 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f1174655b1cef333b69db2dd4bf0d1cfc3442170;p=nmigen.git hdl.ast: tighten assertion in Switch(). --- diff --git a/nmigen/hdl/ast.py b/nmigen/hdl/ast.py index 326ed54..8be490d 100644 --- a/nmigen/hdl/ast.py +++ b/nmigen/hdl/ast.py @@ -1022,12 +1022,12 @@ class Switch(Statement): for key, stmts in cases.items(): if isinstance(key, (bool, int)): key = "{:0{}b}".format(key, len(self.test)) - assert len(key) <= len(self.test) elif isinstance(key, str): - assert len(key) == len(self.test) + pass else: raise TypeError("Object '{!r}' cannot be used as a switch key" .format(key)) + assert len(key) == len(self.test) if not isinstance(stmts, Iterable): stmts = [stmts] self.cases[key] = Statement.wrap(stmts)