diff --git a/xdsl/parser/core.py b/xdsl/parser/core.py index b018f00139..4bf9c5ca1d 100644 --- a/xdsl/parser/core.py +++ b/xdsl/parser/core.py @@ -744,16 +744,23 @@ def _get_op_by_name(self, name: str) -> type[Operation]: Raises an error if the operation is not registered, and if unregistered dialects are not allowed. """ + from xdsl.dialects import builtin + op_type = self.ctx.get_optional_op(name) - if op_type is not None: + + if op_type is not None and not issubclass(op_type, builtin.UnregisteredOp): return op_type for dialect_name in reversed(self._parser_state.dialect_stack): - op_type = self.ctx.get_optional_op(f"{dialect_name}.{name}") - if op_type is not None: - return op_type - - self.raise_error(f"unregistered operation {name}!") + op_with_dialect_type = self.ctx.get_optional_op(f"{dialect_name}.{name}") + if op_with_dialect_type is not None and not issubclass( + op_with_dialect_type, builtin.UnregisteredOp + ): + return op_with_dialect_type + + if op_type is None: + self.raise_error(f"unregistered operation {name}!") + return op_type def _parse_op_result(self) -> tuple[Span, int]: """