diff options
author | Kristóf Marussy <kristof@marussy.com> | 2024-05-20 20:47:39 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2024-05-26 17:22:33 +0200 |
commit | b4a2f3799945fddd3869029c08e7f9d0071e6dee (patch) | |
tree | 7df471874f375187bf7175dab26f7854e89a208b /subprojects/language/src | |
parent | fix(semantics): negative quantification in rules (diff) | |
download | refinery-b4a2f3799945fddd3869029c08e7f9d0071e6dee.tar.gz refinery-b4a2f3799945fddd3869029c08e7f9d0071e6dee.tar.zst refinery-b4a2f3799945fddd3869029c08e7f9d0071e6dee.zip |
fix(language): spurious exception in ProblemValidator
Make sure getNodeArgumentForMultiObjectAssertion runs correctly even for ASTs
with parse errors.
Diffstat (limited to 'subprojects/language/src')
-rw-r--r-- | subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java b/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java index 84af4ee6..0d35fb03 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java +++ b/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java | |||
@@ -520,18 +520,17 @@ public class ProblemValidator extends AbstractProblemValidator { | |||
520 | 520 | ||
521 | @Nullable | 521 | @Nullable |
522 | private Node getNodeArgumentForMultiObjectAssertion(AssertionArgument argument) { | 522 | private Node getNodeArgumentForMultiObjectAssertion(AssertionArgument argument) { |
523 | if (argument instanceof WildcardAssertionArgument) { | 523 | return switch (argument) { |
524 | acceptError("Wildcard arguments for 'exists' are not supported.", argument, null, 0, | 524 | case null -> null; |
525 | UNSUPPORTED_ASSERTION_ISSUE); | 525 | case WildcardAssertionArgument ignoredWildcardAssertionArgument -> { |
526 | return null; | 526 | acceptError("Wildcard arguments for 'exists' are not supported.", argument, null, 0, |
527 | } | 527 | UNSUPPORTED_ASSERTION_ISSUE); |
528 | if (argument instanceof NodeAssertionArgument nodeAssertionArgument) { | 528 | yield null; |
529 | var variableOrNode = nodeAssertionArgument.getNode(); | ||
530 | if (variableOrNode == null || variableOrNode instanceof Node) { | ||
531 | return (Node) variableOrNode; | ||
532 | } | 529 | } |
533 | } | 530 | case NodeAssertionArgument nodeAssertionArgument -> |
534 | throw new IllegalArgumentException("Unknown assertion argument: " + argument); | 531 | nodeAssertionArgument.getNode() instanceof Node node ? node : null; |
532 | default -> throw new IllegalArgumentException("Unknown assertion argument: " + argument); | ||
533 | }; | ||
535 | } | 534 | } |
536 | 535 | ||
537 | @Check | 536 | @Check |