Ticket #53 (closed bug report: fixed)

Opened 5 years ago

Last modified 5 years ago

Illegal class assertion

Reported by: andekar@… Owned by: nibro
Priority: minor Milestone: Full document support
Component: parser Version: 1.0.1
Keywords: Cc:

Description

I try to parse the following file, which is fine in bot ghc and ghic

import Control.Applicative
pEmpty :: ((Functor f),(Applicative f)) ⇒ f [a]
pEmpty = pure []

but i get following error from the parser:

Prelude Language.Haskell.Exts> parseFile "Tmp.hs"
Loading package syb ... linking ... done.
Loading package base-3.0.3.1 ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package pretty-1.0.1.0 ... linking ... done.
Loading package filepath-1.1.0.2 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.2 ... linking ... done.
Loading package unix-2.3.2.0 ... linking ... done.
Loading package directory-1.0.0.3 ... linking ... done.
Loading package process-1.0.1.1 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package cpphs-1.7 ... linking ... done.
Loading package haskell-src-exts-1.0.1 ... linking ... done.
ParseFailed? (SrcLoc? {srcFilename = "Tmp.hs", srcLine = 2, srcColumn = 41}) "Illegal class assertion"

Change History

in reply to: ↑ description   Changed 5 years ago by andekar@…

Replying to andekar@student.chalmers.se:

I try to parse the following file, which is fine in bot ghc and ghic import Control.Applicative
pEmpty :: ((Functor f),(Applicative f)) ⇒ f [a]
pEmpty = pure []
but i get following error from the parser:
Prelude Language.Haskell.Exts> parseFile "Tmp.hs"
Loading package syb ... linking ... done.
Loading package base-3.0.3.1 ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package pretty-1.0.1.0 ... linking ... done.
Loading package filepath-1.1.0.2 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.2 ... linking ... done.
Loading package unix-2.3.2.0 ... linking ... done.
Loading package directory-1.0.0.3 ... linking ... done.
Loading package process-1.0.1.1 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package cpphs-1.7 ... linking ... done.
Loading package haskell-src-exts-1.0.1 ... linking ... done.
ParseFailed? (SrcLoc? {srcFilename = "Tmp.hs", srcLine = 2, srcColumn = 41}) "Illegal class assertion"

It seems the parentheses are the problem, when I removed them, so I have
pEmpty :: (Functor f, Applicative f) ⇒ f [a]
I get the AST.

  Changed 5 years ago by nibro

  • status changed from new to closed
  • resolution set to fixed

The parentheses are indeed the "problem". Having them there is not valid H98, but GHC is more liberal. I find it harmless, so I've added support for having parenthesised assertions to 1.0.2. Case closed, thanks for reporting.

Note: See TracTickets for help on using tickets.