@@ -768,17 +768,25 @@ struct OrderedPredicate {
768768 // / model.
769769 bool operator <(const OrderedPredicate &rhs) const {
770770 // Sort by:
771+ // * not being a constraint. Rational: When writing constraints, it is
772+ // sometimes assumed that checks for null or operation names are executed
773+ // before the constraint. As there is no dependency between this
774+ // operation, this is not always guaranteed, which can lead to bugs if the
775+ // constraints is not checking inputs for null itself. By ordering
776+ // constraints to the end, it is assured that implicit checks are nun
777+ // before them
771778 // * higher first and secondary order sums
772779 // * lower depth
773780 // * lower position dependency
774781 // * lower predicate dependency
775782 // * lower tie breaking ID
776783 auto *rhsPos = rhs.position ;
777- return std::make_tuple (primary, secondary, rhsPos->getOperationDepth (),
784+ return std::make_tuple (!isa<ConstraintQuestion>(question), primary,
785+ secondary, rhsPos->getOperationDepth (),
778786 rhsPos->getKind (), rhs.question ->getKind (), rhs.id ) >
779- std::make_tuple (rhs.primary , rhs.secondary ,
780- position-> getOperationDepth () , position->getKind (),
781- question->getKind (), id);
787+ std::make_tuple (!isa<ConstraintQuestion>( rhs.question ) , rhs.primary ,
788+ rhs. secondary , position->getOperationDepth (),
789+ position-> getKind (), question->getKind (), id);
782790 }
783791};
784792
0 commit comments