Skip to content

Commit b5c51ea

Browse files
committed
core: Parse module correctly when allow-unregistered-dialect is set
1 parent 42681e6 commit b5c51ea

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

xdsl/parser/core.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -744,16 +744,23 @@ def _get_op_by_name(self, name: str) -> type[Operation]:
744744
Raises an error if the operation is not registered, and if unregistered
745745
dialects are not allowed.
746746
"""
747+
from xdsl.dialects import builtin
748+
747749
op_type = self.ctx.get_optional_op(name)
748-
if op_type is not None:
750+
751+
if op_type is not None and not issubclass(op_type, builtin.UnregisteredOp):
749752
return op_type
750753

751754
for dialect_name in reversed(self._parser_state.dialect_stack):
752-
op_type = self.ctx.get_optional_op(f"{dialect_name}.{name}")
753-
if op_type is not None:
754-
return op_type
755-
756-
self.raise_error(f"unregistered operation {name}!")
755+
op_with_dialect_type = self.ctx.get_optional_op(f"{dialect_name}.{name}")
756+
if op_with_dialect_type is not None and not issubclass(
757+
op_with_dialect_type, builtin.UnregisteredOp
758+
):
759+
return op_with_dialect_type
760+
761+
if op_type is None:
762+
self.raise_error(f"unregistered operation {name}!")
763+
return op_type
757764

758765
def _parse_op_result(self) -> tuple[Span, int]:
759766
"""

0 commit comments

Comments
 (0)