projects
/
nmigen.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6beba3a
)
hdl.ast: tighten assertion in Switch().
author
whitequark
<whitequark@whitequark.org>
Thu, 13 Jun 2019 03:56:49 +0000
(
03:56
+0000)
committer
whitequark
<whitequark@whitequark.org>
Thu, 13 Jun 2019 03:56:57 +0000
(
03:56
+0000)
nmigen/hdl/ast.py
patch
|
blob
|
history
diff --git
a/nmigen/hdl/ast.py
b/nmigen/hdl/ast.py
index 326ed54b1922ae58ba03da60b490cbd6b8b3f4d9..8be490d449cfbd861a2e86b2df517540156bb604 100644
(file)
--- 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)