brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 110 forks source link

Simple program fails static type checker #1437

Closed MichaelMMacLeod closed 5 years ago

MichaelMMacLeod commented 5 years ago

Hi there,

I can't seem figure out why this program fails the static type checker:

import image-structs as I

I.color(0, 0, 0, 1)

The error message is

The function application color(x, x, x, 1) expects the applicant [color] to evaluate 
to a function value. The applicant is a Any

Am I missing something really obvious?

Annotating with types doesn't seem to help:

import image-structs as I

x :: I.Color = I.color(0, 0, 0, 1) # same issue
x

It's strange, because if I define color myself, the program type checks fine:

data Color:
  | color(Red :: Number, Green :: Number, Blue :: Number, Alpha :: Number)
end

color(0, 0, 0, 1) # works as expected

(I'm also having this problem with other functions, like color-list-to-bitmap)

Anyone know what's going on?

blerner commented 5 years ago

This isn't your fault; it's a limitation of the image library at the moment. It simply doesn't have the type information propagated, so that when you try to type-check it, Pyret gives up and says "It's something, but I don't know what."

The good news is, we have a replacement image library in the works, which will resolve this issue. That replacement is blocked on some other technical issues, but once we've got those sorted out (which should be soon), we'll be able to resolve this too.

MichaelMMacLeod commented 5 years ago

Ah, okay. Thanks for the quick reply. Looking forward to the new library :).