]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java
Merge "Fix endless loop in type inference for over-applied functions"
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / EApply.java
index 7f50d730b9f0d536fc91f6dfa439f8ccebc43fcd..06ff05c18bf4aec3cb60325734daa382e2544a92 100644 (file)
@@ -249,6 +249,12 @@ public class EApply extends Expression {
             current.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);