]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/TypeChecking.java
(refs #7375) Replace collectRefs by CollectRefsVisitor
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / compilation / TypeChecking.java
index 667c089c3e24fe58561a674622f053a0ed6d9662..52b8692d8f9fcc72394af1bbd0b059399367f077 100644 (file)
@@ -204,6 +204,9 @@ public class TypeChecking {
 
                             Expression expression = value.getExpression();
 
+                            int errorCountBeforeTypeChecking = compilationContext.errorLog.getErrorCount();
+                            int functionArity = expression.getSyntacticFunctionArity();
+                            
                             try {
                                 ArrayList<TVar> vars = new ArrayList<TVar>();
                                 type = Types.removeForAll(type, vars);
@@ -218,6 +221,13 @@ public class TypeChecking {
                                     overloaded.assertResolved(compilationContext.errorLog);
                                 expression.getType().addPolarity(Polarity.POSITIVE);
                                 context.solveSubsumptions(expression.getLocation());
+                                
+                                if(compilationContext.errorLog.getErrorCount() != errorCountBeforeTypeChecking) {
+                                    int typeArity = Types.getArity(type); 
+                                    if(typeArity != functionArity)
+                                        compilationContext.errorLog.logWarning(value.definitionLocation, "Possible problem: type declaration has " + typeArity + " parameter types, but function definition has " + functionArity + " parameters.");
+                                }
+                                
                                 ArrayList<EVariable> demands = context.getConstraintDemand();
                                 if(!demands.isEmpty() || !givenConstraints.isEmpty()) {
                                     ReducedConstraints red = 
@@ -227,7 +237,7 @@ public class TypeChecking {
                                         compilationContext.errorLog.log(c.getDemandLocation(), 
                                                 "Constraint <"+c.constraint+"> is not given and cannot be derived.");
                                     }
-                                    if(compilationContext.errorLog.isEmpty()) { // To prevent exceptions
+                                    if(compilationContext.errorLog.hasNoErrors()) { // To prevent exceptions
                                         expression = ExpressionAugmentation.augmentSolved(
                                                 red.solvedConstraints,
                                                 expression);
@@ -237,7 +247,7 @@ public class TypeChecking {
                                     }
                                 }
                                 else {
-                                    if(compilationContext.errorLog.isEmpty()) // To prevent exceptions
+                                    if(compilationContext.errorLog.hasNoErrors()) // To prevent exceptions
                                         expression = expression.decomposeMatching();
                                 }
                                 expression = expression.closure(vars.toArray(new TVar[vars.size()]));
@@ -398,7 +408,7 @@ public class TypeChecking {
                 for(TransformationRule rule : module.getRules())
                     for(Query[] queries : rule.sections.values())
                         for(Query query : queries)
-                            query.collectRefs(allRefs, refs);                
+                            query.collectRefs(allRefs, refs);
             }
             
             @Override