compiler: error message for custom operations

Emit error messages for custom comparison and inclusion test,
instead of compiler crashing.
This commit is contained in:
pca006132 2020-10-08 19:14:05 +08:00 committed by Sebastien Bourdeauducq
parent 500c0e587f
commit 7406a1f983
1 changed files with 14 additions and 2 deletions

View File

@ -1481,7 +1481,13 @@ class ARTIQIRGenerator(algorithm.Visitor):
return result return result
else: else:
assert False loc = lhs.loc
loc.end = rhs.loc.end
diag = diagnostic.Diagnostic("error",
"Custom object comparison is not supported",
{},
loc)
self.engine.process(diag)
def polymorphic_compare_pair_inclusion(self, needle, haystack): def polymorphic_compare_pair_inclusion(self, needle, haystack):
if builtins.is_range(haystack.type): if builtins.is_range(haystack.type):
@ -1525,7 +1531,13 @@ class ARTIQIRGenerator(algorithm.Visitor):
result = phi result = phi
else: else:
assert False loc = needle.loc
loc.end = haystack.loc.end
diag = diagnostic.Diagnostic("error",
"Custom object inclusion test is not supported",
{},
loc)
self.engine.process(diag)
return result return result