From 65d4a49659fe7b15b1868ab4d2e8f3e16dd3b4c8 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 13 Jun 2019 03:56:49 +0000 Subject: [PATCH] hdl.ast: tighten assertion in Switch(). --- nmigen/hdl/ast.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- 2.30.2