From 04ddb5ee3201d5ef8c241d73de3a7675ac1e9850 Mon Sep 17 00:00:00 2001 From: ansonnazeba Date: Thu, 30 Apr 2026 20:23:15 -0400 Subject: [PATCH] Improve registry type mismatch error --- toolchain/mfc/params/registry.py | 6 +++++- toolchain/mfc/params_tests/test_registry.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/toolchain/mfc/params/registry.py b/toolchain/mfc/params/registry.py index 2d79f00157..1d93eae624 100644 --- a/toolchain/mfc/params/registry.py +++ b/toolchain/mfc/params/registry.py @@ -233,7 +233,11 @@ def register(self, param: ParamDef) -> None: if param.name in self._params: existing = self._params[param.name] if existing.param_type != param.param_type: - raise ValueError(f"Type mismatch for '{param.name}'") + raise ValueError( + f"Type mismatch for '{param.name}': " + f"existing type is {existing.param_type!r}, " + f"new type is {param.param_type!r}" + ) existing.tags.update(param.tags) for tag in param.tags: self._by_tag[tag].add(param.name) diff --git a/toolchain/mfc/params_tests/test_registry.py b/toolchain/mfc/params_tests/test_registry.py index 2f36ca78a3..56d453f335 100644 --- a/toolchain/mfc/params_tests/test_registry.py +++ b/toolchain/mfc/params_tests/test_registry.py @@ -38,7 +38,8 @@ def test_register_type_mismatch_raises(self): with self.assertRaises(ValueError) as ctx: reg.register(ParamDef(name="test", param_type=ParamType.REAL)) - self.assertIn("Type mismatch", str(ctx.exception)) + self.assertIn("existing type is", str(ctx.exception)) + self.assertIn("new type is", str(ctx.exception)) def test_get_params_by_tag(self): """get_params_by_tag should return params with that tag."""