haskell-suite / haskell-src-exts

Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
Other
193 stars 94 forks source link

Parse error for operator `(@:)` when `TypeApplications` is enabled #429

Closed autotaker closed 5 years ago

autotaker commented 5 years ago

The following code is acceptable for GHC-8.6.3 but HSE cannot parse it.

{-# LANGUAGE TypeApplications #-}
(@:) a b = a
$ cabal new-repl --build-depends "haskell-src-exts == 1.21.0"
Resolving dependencies...
Build profile: -w ghc-8.6.3 -O1
In order, the following will be built (use -v for more details):
 - fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Preprocessing library for fake-package-0..
Warning: No exposed modules
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
Prelude Language.Haskell.Exts> parseFileContents "{-# LANGUAGE TypeApplications #-}\n(@:) a b = a\n"
ParseFailed (SrcLoc "<unknown>.hs" 2 3) "Parse error: :"

If TypeApplications is disabled, HSE can parse it.

{-# LANGUAGE NoTypeApplications #-}
(@:) a b = a -- HSE can parse this.

Interestingly, HSE can parse (@+) and (@=) even if TypeApplications is enabled.

{-# LANGUAGE TypeApplications #-}
(@+) a b = a -- OK
(@=) a b = a -- OK
(@:) a b = a -- Parse Error for HSE
autotaker commented 5 years ago

I noticed that this is duplicated to #326. Sorry!