gracelang / minigrace

Self-hosting compiler for the Grace programming language
39 stars 22 forks source link

`where` clauses not recognized in method signatures #336

Open apblack opened 1 year ago

apblack commented 1 year ago

Look at this error message:

basicTypesBundle.grace[14:24]: Syntax error: a type argument list containing a '⟦' must have a matching '⟧'. 
  13:         matches (value:Object) → Boolean
  14:         & (other:Type⟦U where U <: Type⟧) → Type⟦T&U⟧    // answers the join (Self & other)
-----------------------------^

The arrow points to the space before the where. I believe that the where is fine (modulo declaring U somewhere; see language design issue #156). However, miningrace's parser is not expecting a where in this type parameter.

The problem arises because minigrace is confused about the difference between type arguments and type parameters. Come to think if it: I'm confused too. In the above example, the Type... after parameter other: is an applied occurence of a type expression — in other words, a type argument — so everything in it should already be defined. So: can type parameters be qualified by where clauses in method signatures? Should the where go somewhere else?