Opened 23 months ago

Last modified 19 months ago

#11540 new bug

ghc accepts non-standard type without language extension

Reported by: augustss Owned by:
Priority: normal Milestone:
Component: Compiler (Parser) Version: 7.8.4
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:

Description

Ghc accepts this

f :: Eq a => Eq b => a -> b -> Bool
f a b = a==a && b==b

The nested contexts should require some language extension.

Change History (5)

comment:1 Changed 23 months ago by bgamari

Component: CompilerCompiler (Parser)

Hmmm, fair enough. Perhaps -XNestedContexts?

comment:2 Changed 23 months ago by rwbarton

If we want to control this with a language extension, then Rank2Types/RankNTypes should be a good choice. After all we already have

Prelude> let f :: a -> Eq a => a; f = undefined

<interactive>:4:10:
    Illegal polymorphic or qualified type: Eq a => a
    Perhaps you intended to use RankNTypes or Rank2Types
    In the type signature for ‘f’: f :: a -> Eq a => a

comment:3 Changed 22 months ago by bgamari

That being said, it was decided at some point that we should also allow forall independently from RankNTypes with ExplicitForAll. My initial thought was that RankNTypes would imply NestedContexts, just as it does ExplicitForAll.

Last edited 22 months ago by bgamari (previous) (diff)

comment:4 Changed 22 months ago by simonpj

I'd be happy to see this checked, if someone wants to have a go, but I doubt that it's a very high priority.

comment:5 Changed 19 months ago by simonpj

Moreover, the current treatment (allowing nested contexts) is inconsistent with GADTs (#12087), which is undesirable.

Nothing hard here; just gotta decide what we want and implement it.

Note: See TracTickets for help on using tickets.