Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghc-lib-parser 9.10 #1103

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: [ghc947, ghc963, ghc981]
ghc: [ghc965, ghc982, ghc9101]
name: Build and test on ${{ matrix.ghc }}
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## Unreleased

* Switched to `ghc-lib-parser-9.10`, with the following new syntactic features/behaviors:
* GHC proposal [#575](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0575-deprecated-instances.rst): deprecated instances.
* GHC proposal [#281](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0281-visible-forall.rst): visible forall in types of terms.
Enabled by `RequiredTypeArguments` (enabled by default).
* `LinearTypes`: `let` and `where` bindings can now be linear, in particular have multiplicity annotations.
* Using `forall` as an identifier is now a parse error.
* GHC proposal [#65](https://github.com/ghc-proposals/ghc-proposals/blob/10290a668608d608c3f6c6010be265cf7a02e1fc/proposals/0065-type-infix.rst): namespacing fixity declarations for type names and WARNING/DEPRECATED pragmas.
* `TypeAbstractions` now supports `@`-binders in lambdas and function equations.
* Support for the `GHC2024` language.

* Updated to `Cabal-syntax-3.12`.

## Ormolu 0.7.4.0

* Don't error when the `JavaScriptFFI` language pragma is present. [Issue
Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages: . extract-hackage-info

tests: True

constraints: ormolu +dev
6 changes: 3 additions & 3 deletions data/examples/backpack/signature-0-out.hsig
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ instance Primitive Prim

name :: String

-- \| The name of the primitive used as the seed stretcher
-- \| Test line 2
-- | The name of the primitive used as the seed stretcher
-- | Test line 2
-- | Test line 3
-- \|Test line 4
-- |Test line 4
Comment on lines -18 to +21
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was curious why this changed. Seems like GHC merged a change that causes signature modules to now parse Haddocks correctly. So now ghc-lib-parser returns an AST containing HsDocStringChunk " | Test line 2" instead of the previously incorrect EpaLineComment " \\| Test line 2".

However, now I see that these docs are in two places: in an EpaComments annotation and in a DocD declaration. I can't find the logic that prevents Ormolu from printing these out twice. Anyone know where that is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, now I see that these docs are in two places: in an EpaComments annotation and in a DocD declaration.

Yeah, this has always been the case, see e.g. #901 (comment) for another example/more context.

I can't find the logic that prevents Ormolu from printing these out twice. Anyone know where that is?

It is here, specifically line 75:

-- We want to extract all comments except _valid_ Haddock comments
rawComments0 =
fmap (uncurry L)
. M.toAscList
. flip M.withoutKeys validHaddockCommentSpans
. M.fromList
. fmap (\(L l a) -> (l, a))
$ allComments

primName :: String

randomBlocks ::
Expand Down
2 changes: 2 additions & 0 deletions data/examples/declaration/signature/fixity/infix-out.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ infix 0 <?>
infix 9 <^-^>

infix 2 ->

infix 0 type <!>
2 changes: 2 additions & 0 deletions data/examples/declaration/signature/fixity/infix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ infix 0 <?>
infix 9 <^-^>

infix 2 ->

infix 0 type <!>
2 changes: 2 additions & 0 deletions data/examples/declaration/signature/fixity/infixl-out.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
infixl 8 ***

infixl 0 $, *, +, &&, **

infixl 9 type $
2 changes: 2 additions & 0 deletions data/examples/declaration/signature/fixity/infixl.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
infixl 8 ***
infixl 0 $, *, +, &&, **

infixl 9 type $
2 changes: 2 additions & 0 deletions data/examples/declaration/signature/fixity/infixr-out.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
infixr 8 `Foo`

infixr 0 ***, &&&

infixr 0 data $
2 changes: 2 additions & 0 deletions data/examples/declaration/signature/fixity/infixr.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
infixr 8 `Foo`
infixr 0 ***, &&&

infixr 0 data $
2 changes: 1 addition & 1 deletion data/examples/declaration/value/function/pragmas-out.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sccfoo = {-# SCC foo #-} 1
sccfoo = {-# SCC "foo" #-} 1
amesgen marked this conversation as resolved.
Show resolved Hide resolved

sccbar =
{-# SCC "barbaz" #-}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
vshow :: forall a -> (Show a) => a -> String
vshow t x = show (x :: t)

s1 = vshow Int 42

s2 = vshow Double 42

a1 = f (type (Int -> Bool))

a2 = f (type ((Read T) => T))

a3 = f (type (forall a. a))

a4 = f (type (forall a. (Read a) => String -> a))

foo =
f
( type ( Maybe
Int
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
vshow :: forall a -> Show a => a -> String
vshow t x = show (x :: t)

s1 = vshow Int 42
s2 = vshow Double 42

a1 = f (type (Int -> Bool))
a2 = f (type (Read T => T))
a3 = f (type (forall a. a))
a4 = f (type (forall a. Read a => String -> a))

foo = f (type (Maybe
Int))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
id :: forall a. a -> a
id @t x = x :: t

f1 :: forall a. a -> forall b. b -> (a, b)
f1 @a x @b y = (x :: a, y :: b)

f2 =
(\ @a x @b y -> (x :: a, y :: b)) ::
forall a. a -> forall b. b -> (a, b)
8 changes: 8 additions & 0 deletions data/examples/declaration/value/function/type-abstractions.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
id :: forall a. a -> a
id @t x = x :: t

f1 :: forall a. a -> forall b. b -> (a, b)
f1 @a x @b y = (x :: a, y :: b)

f2 = (\ @a x @b y -> (x :: a, y :: b) )
:: forall a. a -> forall b. b -> (a, b)
9 changes: 9 additions & 0 deletions data/examples/declaration/warning/warning-multiline-out.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@
#-}
test :: IO ()
test = pure ()

instance
{-# WARNING "Don't use" #-}
Show G1 where
show = "G1"

deriving instance
{-# WARNING "to be removed" #-}
Eq G2
8 changes: 8 additions & 0 deletions data/examples/declaration/warning/warning-multiline.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
foo ["These are bad functions", "Really bad!"] #-}
test :: IO ()
test = pure ()

instance
{-# WARNING "Don't use" #-}
Show G1 where
show = "G1"

deriving instance
{-# WARNING "to be removed" #-} Eq G2
12 changes: 10 additions & 2 deletions data/examples/declaration/warning/warning-single-line-out.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ test = pure ()
bar = 3
{-# DEPRECATED bar "Bar is deprecated" #-}

{-# DEPRECATED baz "Baz is also deprecated" #-}
{-# DEPRECATED data baz "Baz is also deprecated" #-}
baz = 5

data Number = Number Dobule
{-# DEPRECATED Number "Use Scientific instead." #-}
{-# DEPRECATED type Number "Use Scientific instead." #-}

head (a : _) = a
{-# WARNING in "x-partial" head "This function is partial..." #-}

instance {-# DEPRECATED "Don't use" #-} Show T1

instance {-# WARNING "Don't use either" #-} Show G1

deriving instance {-# DEPRECATED "to be removed" #-} Eq T2

deriving instance {-# WARNING "to be removed as well" #-} Eq G2
10 changes: 8 additions & 2 deletions data/examples/declaration/warning/warning-single-line.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ bar = 3

{-# Deprecated bar "Bar is deprecated" #-}

{-# DEPRECATED baz "Baz is also deprecated" #-}
{-# DEPRECATED data baz "Baz is also deprecated" #-}
baz = 5

data Number = Number Dobule
{-# DEPRECATED Number "Use Scientific instead." #-}
{-# DEPRECATED type Number "Use Scientific instead." #-}

head (a:_) = a
{-# WARNING in "x-partial" head "This function is partial..." #-}

instance {-# DEPRECATED "Don't use" #-} Show T1 where
instance {-# WARNING "Don't use either" #-} Show G1 where

deriving instance {-# DEPRECATED "to be removed" #-} Eq T2
deriving instance {-# WARNING "to be removed as well" #-} Eq G2
12 changes: 12 additions & 0 deletions data/examples/import/docstrings-after-exports-out.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Test
( since1, -- ^ @since 1.0
since2, -- ^ @since 2.0
since3, -- ^ @since 3.0
SinceType (..), -- ^ @since 4.0
SinceClass (..), -- ^ @since 5.0
Multi (..),
-- ^ since 6.0
-- multi
-- line
)
where
11 changes: 11 additions & 0 deletions data/examples/import/docstrings-after-exports.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Test (
since1, -- ^ @since 1.0
since2 -- ^ @since 2.0
, since3 -- ^ @since 3.0
, SinceType(..) -- ^ @since 4.0
, SinceClass(..) -- ^ @since 5.0
, Multi(..)
-- ^ since 6.0
-- multi
-- line
) where
48 changes: 0 additions & 48 deletions expected-failures/Agda.txt

This file was deleted.

2 changes: 0 additions & 2 deletions expected-failures/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
let
inherit (pkgs) lib;
expectedFailures = [
"Agda"
"brittany"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see!

"esqueleto"
"hlint"
Expand All @@ -12,7 +11,6 @@ let
"pandoc"
"pipes"
"postgrest"
"purescript"
];
ormolizedPackages =
let
Expand Down
2 changes: 1 addition & 1 deletion expected-failures/hlint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ src/Extension.hs
Formatting is not idempotent.
Please, consider reporting the bug.
src/Hint/Bracket.hs
@@ -258,8 +258,11 @@
@@ -265,8 +265,11 @@
let y = noLocA $ HsApp EpAnnNotUsed a1 (nlHsPar a2),
let r = Replace Expr (toSSA e) [("a", toSSA a1), ("b", toSSA a2)] "a (b)"
]
Expand Down
16 changes: 0 additions & 16 deletions expected-failures/leksah.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,3 @@ src/IDE/Find.hs:615:36-46
The GHC parser (in Haddock mode) failed:
[GHC-95644] Bang pattern in expression context: !matchIndex
Did you mean to add a space after the '!'?
src/IDE/Pane/Modules.hs
@@ -1183,9 +1183,9 @@
let modId = mdModuleId modDescr
modName = modu modId
mFilePath = mdMbSourcePath modDescr
- -- show relative file path for Main modules
+ in -- show relative file path for Main modules
-- since we can have several
- in case (components modName, mFilePath) of
+ case (components modName, mFilePath) of
(["Main"], Just fp) ->
let sfp = case (pdMbSourcePath (snd pair)) of
Nothing -> fp

Formatting is not idempotent.
Please, consider reporting the bug.
14 changes: 0 additions & 14 deletions expected-failures/pandoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,3 @@ src/Text/Pandoc/Readers/Org/Inlines.hs

Formatting is not idempotent.
Please, consider reporting the bug.
src/Text/Pandoc/Readers/RST.hs
@@ -1125,7 +1125,7 @@
-- if no ":class:" field is given, the default is the role name
classFieldClasses = maybe [role] T.words (lookup "class" fields)
- -- nub in case role name & language class are the same
- in nub (classFieldClasses ++ codeLanguageClass ++ oldClasses)
+ in -- nub in case role name & language class are the same
+ nub (classFieldClasses ++ codeLanguageClass ++ oldClasses)

attr =
let (ident, baseClasses, keyValues) = baseAttr

Formatting is not idempotent.
Please, consider reporting the bug.
41 changes: 0 additions & 41 deletions expected-failures/purescript.txt

This file was deleted.

Loading