Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#7402 closed feature request (fixed)

Warn about possible missing -XScopedTypeVariables on errors.

Reported by: Aninhumer Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Suggest that the user they may wish to add -XScopedTypeVariables, if an error results from a free type variable which would be bound in its scope with the flag enabled. (i.e. if its name exists as a variable in the type declaration).

I ran into this problem on code similar to this:

instance (Sized a n, Nat n) => Rep a where
    emptyRep = replicate (toInt (undefined :: n)) 0

and it took me some time to solve, and only by having vague knowledge that such a flag existed.

Change History (2)

comment:1 Changed 4 years ago by simonpj

difficulty: Unknown
Resolution: fixed
Status: newclosed

Good point. I've tightened up the ambiguity check for instance declarations. Now you'll get an "ambiguous declaration" error from the above.


comment:2 Changed 4 years ago by simonpj

Actually I was mixed up. The ambiguity fix would reject this instance, but the original question was about scoped type variables. The trouble is that this is a perfectly legal program without scoped type variables, with the 'n' meaning "forall n. n". I'm not sure how to improve this.


Note: See TracTickets for help on using tickets.