Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type mismatch (expected: 'Double', found: 'Unknown Class') with wildcard types #48

Open
abstratt opened this issue Feb 18, 2015 · 0 comments
Labels

Comments

@abstratt
Copy link
Owner

    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
abstratt added a commit to abstratt/cloudfier-examples that referenced this issue Feb 23, 2015
@abstratt abstratt added the bug label Nov 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant