Skip to content

Commit 36fc04c

Browse files
Improve registry type mismatch error (#1390)
Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
1 parent 1033ff6 commit 36fc04c

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

toolchain/mfc/params/registry.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,11 @@ def register(self, param: ParamDef) -> None:
233233
if param.name in self._params:
234234
existing = self._params[param.name]
235235
if existing.param_type != param.param_type:
236-
raise ValueError(f"Type mismatch for '{param.name}'")
236+
raise ValueError(
237+
f"Type mismatch for '{param.name}': "
238+
f"existing type is {existing.param_type!r}, "
239+
f"new type is {param.param_type!r}"
240+
)
237241
existing.tags.update(param.tags)
238242
for tag in param.tags:
239243
self._by_tag[tag].add(param.name)

toolchain/mfc/params_tests/test_registry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def test_register_type_mismatch_raises(self):
3838
with self.assertRaises(ValueError) as ctx:
3939
reg.register(ParamDef(name="test", param_type=ParamType.REAL))
4040

41-
self.assertIn("Type mismatch", str(ctx.exception))
41+
self.assertIn("existing type is", str(ctx.exception))
42+
self.assertIn("new type is", str(ctx.exception))
4243

4344
def test_get_params_by_tag(self):
4445
"""get_params_by_tag should return params with that tag."""

0 commit comments

Comments
 (0)