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

Internal error when typechecking malformed forall clause #91

Open
patrickt opened this issue Oct 3, 2018 · 3 comments
Open

Internal error when typechecking malformed forall clause #91

patrickt opened this issue Oct 3, 2018 · 3 comments
Labels

Comments

@patrickt
Copy link

patrickt commented Oct 3, 2018

Here’s a function with more than one constraint, that typechecks fine:

(defn show-equal : (forall [s] (Show s) (Eq s) => {s -> s -> Bool})
  [[a b] { {a == b} && {(show a) == (show b)}}])

I originally messed up the syntax, and thought that forall’s second parameter was a list:

(forall [s] ((Show s) (Eq s)) => {s -> s -> Bool})

When the typechecker tries to inspect this, I get an internal error:

../../../../Applications/Racket v7.0/collects/racket/private/map.rkt:180:2: andmap: all lists must have same size
  first list length: 1
  other list length: 2
  procedure: #<procedure:types-match?!>
@iitalics
Copy link
Contributor

iitalics commented Oct 3, 2018

I get a similar but different error. Which commit are you on and which version of Racket are you running?

@lexi-lambda lexi-lambda added the bug label Oct 3, 2018
@patrickt
Copy link
Author

patrickt commented Oct 3, 2018

@iitalics This is with Racket 7.0 and a Hackett installed from raco pkg, which appears to have targeted f5a080e.

@lexi-lambda
Copy link
Owner

Here’s what is happening:

  1. ((Show s) (Eq s)) is the same as (Show s (Eq s)).

  2. The typechecker looks up the information for Show and tries to zip the argument types with the instance type variables.

  3. The arity mismatch is never caught, so the typechecker explodes.

The easy fix would be to insert some ad-hoc arity-checking code that complains about the mismatch. The right fix is to implement actual kindchecking, since (Show s (Eq s)) is an ill-kinded type. I’ve been putting kindchecking off for ages, though, since it would take a lot of thought and possibly some serious refactoring, so maybe the quick fix is the right thing for now.

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

3 participants