- effect = mfun.effect;
-
- context.declareEffect(location, mfun.effect);
- setType(mfun.returnType);
+ if(marity < current.parameters.length) {
+ if (marity == 0) {
+ // Cannot eat away any more parameters
+ context.getErrorLog().log(location, "Application of non-function");
+ return current;
+ }
+
+ Expression[] missingParameters = Arrays.copyOfRange(current.parameters, marity, current.parameters.length);
+ functionType = mfun.returnType;
+ current.parameters = Arrays.copyOf(current.parameters, marity);
+ current = new EApply(current, missingParameters);
+ }
+ else {
+ if((ignoreResult && mfun.effect == Types.NO_EFFECTS && Skeletons.canonicalSkeleton(mfun.returnType) instanceof TFun) ||
+ (context.isInPattern() && Skeletons.canonicalSkeleton(mfun.returnType) instanceof TFun)) {
+ context.getErrorLog().log(location, "The function is applied with too few parameters.");
+ }
+ return current;
+ }
+ }