Skip to content

Commit

Permalink
Fix apply_0 crashing on operators with input
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jun 23, 2024
1 parent 858ea6f commit 4d36d5d
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,23 @@ public class OperatorBuilders {
public static final IterativeFunction.PrePostBuilder<Pair<IOperator, OperatorBase.SafeVariablesGetter>, IValue> FUNCTION_OPERATOR_TAKE_OPERATOR = IterativeFunction.PrePostBuilder.begin()
.appendPre(input -> {
IOperator innerOperator = input.getValue(0, ValueTypes.OPERATOR).getRawValue();
if (innerOperator.getRequiredInputLength() == 1) {
IValue applyingValue = input.getValue(1);
MutableComponent error = innerOperator.validateTypes(new IValueType[]{applyingValue.getType()});
if (error != null) {
throw new EvaluationException(error);
}
} else if (innerOperator.getRequiredInputLength() > 0) {
if (!ValueHelpers.correspondsTo(input.getVariables()[1].getType(), innerOperator.getInputTypes()[0])) {
MutableComponent error = Component.translatable(L10NValues.OPERATOR_ERROR_WRONGCURRYINGTYPE,
Component.translatable(innerOperator.getTranslationKey()),
Component.translatable(input.getVariables()[1].getType().getTranslationKey()),
0,
Component.translatable(innerOperator.getInputTypes()[0].getTranslationKey())
);
throw new EvaluationException(error);
if (input.getVariables().length > 1) {
if (innerOperator.getRequiredInputLength() == 1) {
IValue applyingValue = input.getValue(1);
MutableComponent error = innerOperator.validateTypes(new IValueType[]{applyingValue.getType()});
if (error != null) {
throw new EvaluationException(error);
}
} else if (innerOperator.getRequiredInputLength() > 0) {
if (!ValueHelpers.correspondsTo(input.getVariables()[1].getType(), innerOperator.getInputTypes()[0])) {
MutableComponent error = Component.translatable(L10NValues.OPERATOR_ERROR_WRONGCURRYINGTYPE,
Component.translatable(innerOperator.getTranslationKey()),
Component.translatable(input.getVariables()[1].getType().getTranslationKey()),
0,
Component.translatable(innerOperator.getInputTypes()[0].getTranslationKey())
);
throw new EvaluationException(error);
}
}
}
return Pair.<IOperator, OperatorBase.SafeVariablesGetter>of(innerOperator,
Expand Down

0 comments on commit 4d36d5d

Please sign in to comment.