You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private query totalExpenses(toSum : Expense[*]) : Double;
begin
return toSum.reduce((e : Expense, sum : Double) : Double {
sum + e.amount
}, 0);
end;
Error: Type mismatch (expected: 'Double', found: 'Unknown Class')
The problem here is that the parameter 0 is of type Integer, and the definition of reduce requires the second parameter of the closure and the initial value to have the exact same type, and they are double in the closure passed in. Since there is no single type we can unify the call values to, the result type (which is also the same wildcard type) is left unresolved (wildcard types don't have names internally, and are only referred to by context-specific aliases).
A few things here:
the message is not really helpful, we could suggest the names of types we could take
we are able to implicitly cast integers to doubles elsewhere, the exact match required here is counter-intuitive
it seems the operation lookup works by falling back to the original operation definition (with wildcard types) - that should be an error condition
The text was updated successfully, but these errors were encountered:
abstratt
added a commit
to abstratt/cloudfier-examples
that referenced
this issue
Feb 23, 2015
Error: Type mismatch (expected: 'Double', found: 'Unknown Class')
The problem here is that the parameter 0 is of type Integer, and the definition of reduce requires the second parameter of the closure and the initial value to have the exact same type, and they are double in the closure passed in. Since there is no single type we can unify the call values to, the result type (which is also the same wildcard type) is left unresolved (wildcard types don't have names internally, and are only referred to by context-specific aliases).
A few things here:
The text was updated successfully, but these errors were encountered: