[Git][ghc/ghc][wip/backports-8.10] 6 commits: Fix bad span calculations of post qualified imports

Ben Gamari gitlab at gitlab.haskell.org
Mon Dec 14 19:13:55 UTC 2020



Ben Gamari pushed to branch wip/backports-8.10 at Glasgow Haskell Compiler / GHC


Commits:
fac6a05d by Shayne Fletcher at 2020-12-14T14:13:49-05:00
Fix bad span calculations of post qualified imports

(cherry picked from commit 57f3fdb1fbeb82b5b19bc5e2970d8857c2514fcc)

- - - - -
5072f019 by Ben Gamari at 2020-12-14T14:13:49-05:00
gitlab-ci: Rename RELEASE variable to RELEASE_JOB

This interfered with the autoconf variable of the same name, breaking
pre-release builds.

(cherry picked from commit 15dca84793d5ec4ff922726477923e40caa075eb)
(cherry picked from commit 3e55edd97c8eba271f5cb64b9362796791e0e887)

- - - - -
86c8c8df by Ben Gamari at 2020-12-14T14:13:49-05:00
configure: Release 8.10.3

- - - - -
8e548f38 by Ben Gamari at 2020-12-14T14:13:49-05:00
Disable deprecation warnings in Cabal build

- - - - -
a4c19abe by Ben Gamari at 2020-12-14T14:13:49-05:00
hadrian: Reindent Settings.Warnings

The previous state was quite illegible.

- - - - -
0b3497ef by Ben Gamari at 2020-12-14T14:13:49-05:00
hadrian: Pass -Werror before other arguments

Previously we would append -Werror to the argument list. However, this
ended up overriding the -Wno-error=... flags in Settings.Warnings.

- - - - -


10 changed files:

- .gitlab-ci.yml
- compiler/parser/Parser.y
- configure.ac
- hadrian/src/Flavour.hs
- hadrian/src/Settings/Warnings.hs
- libraries/text
- mk/warnings.mk
- testsuite/tests/module/all.T
- + testsuite/tests/module/mod185.hs
- + testsuite/tests/module/mod185.stderr


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -52,7 +52,7 @@ stages:
     expire_in: 1 year
   only:
     variables:
-      - $RELEASE == "yes"
+      - $RELEASE_JOB == "yes"
 
 ############################################################
 # Runner Tags


=====================================
compiler/parser/Parser.y
=====================================
@@ -973,18 +973,20 @@ importdecls_semi
 importdecl :: { LImportDecl GhcPs }
         : 'import' maybe_src maybe_safe optqualified maybe_pkg modid optqualified maybeas maybeimpspec
                 {% do {
-                  ; checkImportDecl $4 $7
-                  ; ams (cL (comb4 $1 $6 (snd $8) $9) $
+                  ; let { ; mPreQual = unLoc $4
+                          ; mPostQual = unLoc $7 }
+                  ; checkImportDecl mPreQual mPostQual
+                  ; ams (cL (comb5 $1 $6 $7 (snd $8) $9) $
                       ImportDecl { ideclExt = noExtField
                                   , ideclSourceSrc = snd $ fst $2
                                   , ideclName = $6, ideclPkgQual = snd $5
                                   , ideclSource = snd $2, ideclSafe = snd $3
-                                  , ideclQualified = importDeclQualifiedStyle $4 $7
+                                  , ideclQualified = importDeclQualifiedStyle mPreQual mPostQual
                                   , ideclImplicit = False
                                   , ideclAs = unLoc (snd $8)
                                   , ideclHiding = unLoc $9 })
-                         (mj AnnImport $1 : fst (fst $2) ++ fst $3 ++ fmap (mj AnnQualified) (maybeToList $4)
-                                          ++ fst $5 ++ fmap (mj AnnQualified) (maybeToList $7) ++ fst $8)
+                         (mj AnnImport $1 : fst (fst $2) ++ fst $3 ++ fmap (mj AnnQualified) (maybeToList mPreQual)
+                                          ++ fst $5 ++ fmap (mj AnnQualified) (maybeToList mPostQual) ++ fst $8)
                   }
                 }
 
@@ -1008,9 +1010,9 @@ maybe_pkg :: { ([AddAnn],Maybe StringLiteral) }
                         ; return ([mj AnnPackageName $1], Just (StringLiteral (getSTRINGs $1) pkgFS)) } }
         | {- empty -}                           { ([],Nothing) }
 
-optqualified :: { Maybe (Located Token) }
-        : 'qualified'                           { Just $1 }
-        | {- empty -}                           { Nothing }
+optqualified :: { Located (Maybe (Located Token)) }
+        : 'qualified'                           { sL1 $1 (Just $1) }
+        | {- empty -}                           { noLoc Nothing }
 
 maybeas :: { ([AddAnn],Located (Maybe (Located ModuleName))) }
         : 'as' modid                           { ([mj AnnAs $1]
@@ -3896,6 +3898,11 @@ comb4 a b c d = a `seq` b `seq` c `seq` d `seq`
     (combineSrcSpans (getLoc a) $ combineSrcSpans (getLoc b) $
                 combineSrcSpans (getLoc c) (getLoc d))
 
+comb5 :: Located a -> Located b -> Located c -> Located d -> Located e -> SrcSpan
+comb5 a b c d e = a `seq` b `seq` c `seq` d `seq` e `seq`
+    (combineSrcSpans (getLoc a) $ combineSrcSpans (getLoc b) $
+       combineSrcSpans (getLoc c) $ combineSrcSpans (getLoc d) (getLoc e))
+
 -- strict constructor version:
 {-# INLINE sL #-}
 sL :: HasSrcSpan a => SrcSpan -> SrcSpanLess a -> a


=====================================
configure.ac
=====================================
@@ -13,10 +13,10 @@ dnl
 # see what flags are available. (Better yet, read the documentation!)
 #
 
-AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.2], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION])
+AC_INIT([The Glorious Glasgow Haskell Compilation System], [8.10.3], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION])
 
 # Set this to YES for a released version, otherwise NO
-: ${RELEASE=NO}
+: ${RELEASE=YES}
 
 # The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line
 # above.  If this is not a released version, then we will append the


=====================================
hadrian/src/Flavour.hs
=====================================
@@ -2,7 +2,7 @@ module Flavour
   ( Flavour (..), werror
   , DocTargets, DocTarget(..)
     -- * Flavour transformers
-  , addArgs
+  , addArgs, addArgsBefore
   , splitSections, splitSectionsIf
   , enableThreadSanitizer
   , enableDebugInfo, enableTickyGhc
@@ -71,10 +71,15 @@ data DocTarget = Haddocks | SphinxHTML | SphinxPDFs | SphinxMan | SphinxInfo
 addArgs :: Args -> Flavour -> Flavour
 addArgs args' fl = fl { args = args fl <> args' }
 
+addArgsBefore :: Args -> Flavour -> Flavour
+addArgsBefore args' fl = fl { args = args' <> args fl }
+
 -- | Turn on -Werror for packages built with the stage1 compiler.
 -- It mimics the CI settings so is useful to turn on when developing.
 werror :: Flavour -> Flavour
-werror = addArgs (builder Ghc ? notStage0 ? arg "-Werror")
+werror = addArgsBefore (builder Ghc ? notStage0 ? arg "-Werror")
+  -- N.B. We add this flag *before* the others to ensure that we don't override
+  -- the -Wno-error flags defined in "Settings.Warnings".
 
 -- | Build C and Haskell objects with debugging information.
 enableDebugInfo :: Flavour -> Flavour


=====================================
hadrian/src/Settings/Warnings.hs
=====================================
@@ -20,35 +20,39 @@ ghcWarningsArgs = do
     isIntegerSimple <- (== integerSimple) <$> getIntegerPackage
     mconcat
         [ stage0 ? mconcat
-        [ libraryPackage       ? pure [ "-fno-warn-deprecated-flags" ]
-        , package terminfo     ? pure [ "-fno-warn-unused-imports" ]
-        , package transformers ? pure [ "-fno-warn-unused-matches"
-                                      , "-fno-warn-unused-imports" ] ]
+          [ libraryPackage       ? pure [ "-fno-warn-deprecated-flags" ]
+          , package terminfo     ? pure [ "-fno-warn-unused-imports" ]
+          , package transformers ? pure [ "-fno-warn-unused-matches"
+                                        , "-fno-warn-unused-imports" ] ]
         , notStage0 ? mconcat
-        [ libraryPackage       ? pure [ "-Wno-deprecated-flags" ]
-        , package base         ? pure [ "-Wno-trustworthy-safe" ]
-        , package binary       ? pure [ "-Wno-deprecations" ]
-        , package bytestring   ? pure [ "-Wno-inline-rule-shadowing" ]
-        , package compiler     ? pure [ "-Wcpp-undef" ]
-        , package directory    ? pure [ "-Wno-unused-imports" ]
-        , package ghc          ? pure [ "-Wcpp-undef" ]
-        , package ghcPrim      ? pure [ "-Wno-trustworthy-safe" ]
-        , package haddock      ? pure [ "-Wno-unused-imports"
-                                      , "-Wno-deprecations" ]
-        , package haskeline    ? pure [ "-Wno-deprecations"
-                                      , "-Wno-unused-imports"
-                                      , "-Wno-redundant-constraints"
-                                      , "-Wno-simplifiable-class-constraints" ]
-        , package pretty       ? pure [ "-Wno-unused-imports" ]
-        , package primitive    ? pure [ "-Wno-unused-imports"
-                                      , "-Wno-deprecations" ]
-        , package rts          ? pure [ "-Wcpp-undef" ]
-        , package terminfo     ? pure [ "-Wno-unused-imports" ]
-        , isIntegerSimple      ?
-          package text         ? pure [ "-Wno-unused-imports" ]
-        , package transformers ? pure [ "-Wno-unused-matches"
-                                      , "-Wno-unused-imports"
-                                      , "-Wno-redundant-constraints"
-                                      , "-Wno-orphans" ]
-        , package win32        ? pure [ "-Wno-trustworthy-safe" ]
-        , package xhtml        ? pure [ "-Wno-unused-imports" ] ] ]
+          [ libraryPackage       ? pure [ "-Wno-deprecated-flags" ]
+          , package base         ? pure [ "-Wno-trustworthy-safe" ]
+          , package binary       ? pure [ "-Wno-deprecations" ]
+          , package bytestring   ? pure [ "-Wno-inline-rule-shadowing" ]
+          , package compiler     ? pure [ "-Wcpp-undef" ]
+          , package directory    ? pure [ "-Wno-unused-imports" ]
+          , package ghc          ? pure [ "-Wcpp-undef" ]
+          , package ghcPrim      ? pure [ "-Wno-trustworthy-safe" ]
+          , package haddock      ? pure [ "-Wno-unused-imports"
+                                        , "-Wno-deprecations" ]
+          , package haskeline    ? pure [ "-Wno-deprecations"
+                                        , "-Wno-unused-imports"
+                                        , "-Wno-redundant-constraints"
+                                        , "-Wno-simplifiable-class-constraints" ]
+          , package pretty       ? pure [ "-Wno-unused-imports" ]
+          , package primitive    ? pure [ "-Wno-unused-imports"
+                                        , "-Wno-deprecations" ]
+          , package rts          ? pure [ "-Wcpp-undef" ]
+          , package terminfo     ? pure [ "-Wno-unused-imports" ]
+          , isIntegerSimple      ?
+            package text         ? pure [ "-Wno-unused-imports" ]
+          , package transformers ? pure [ "-Wno-unused-matches"
+                                        , "-Wno-unused-imports"
+                                        , "-Wno-redundant-constraints"
+                                        , "-Wno-orphans" ]
+          , package win32        ? pure [ "-Wno-trustworthy-safe" ]
+          , package xhtml        ? pure [ "-Wno-unused-imports" ]
+          ]
+        , mconcat
+          [ package cabal        ? pure [ "-Wno-error=deprecations" ] ]
+        ]


=====================================
libraries/text
=====================================
@@ -1 +1 @@
-Subproject commit be54b46175db603aafea3e3f19a6a75e87a29828
+Subproject commit e07c14940c25f33fe5b282912d745d3a79dd4ade


=====================================
mk/warnings.mk
=====================================
@@ -80,6 +80,8 @@ libraries/haskeline_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports
 libraries/haskeline_dist-install_EXTRA_HC_OPTS += -Wno-redundant-constraints
 libraries/haskeline_dist-install_EXTRA_HC_OPTS += -Wno-simplifiable-class-constraints
 
+# Due to deprecation warning
+libraries/Cabal_dist-install_EXTRA_HC_OPTS += -Wno-error=deprecations
 
 # temporarily turn off unused-imports warnings for pretty
 libraries/pretty_dist-install_EXTRA_HC_OPTS += -Wno-unused-imports


=====================================
testsuite/tests/module/all.T
=====================================
@@ -268,6 +268,7 @@ test('mod181', normal, compile, [''])
 test('mod182', normal, compile_fail, [''])
 test('mod183', normal, compile_fail, [''])
 test('mod184', normal, compile, ['-Wprepositive-qualified-module'])
+test('mod185', normal, compile, ['-ddump-parsed-ast'])
 
 test('T1148', normal, compile, [''])
 test('T1074', normal, compile, [''])


=====================================
testsuite/tests/module/mod185.hs
=====================================
@@ -0,0 +1,5 @@
+{-# LANGUAGE ImportQualifiedPost #-}
+-- The span of the import decl should include the 'qualified' keyword.
+import Prelude qualified
+
+main = Prelude.undefined


=====================================
testsuite/tests/module/mod185.stderr
=====================================
@@ -0,0 +1,61 @@
+==================== Parser AST ====================
+
+({ mod185.hs:1:1 }
+ (HsModule
+  (Nothing)
+  (Nothing)
+  [({ mod185.hs:3:1-24 }
+    (ImportDecl
+     (NoExtField)
+     (NoSourceText)
+     ({ mod185.hs:3:8-14 }
+      {ModuleName: Prelude})
+     (Nothing)
+     (False)
+     (False)
+     (QualifiedPost)
+     (False)
+     (Nothing)
+     (Nothing)))]
+  [({ mod185.hs:5:1-24 }
+    (ValD
+     (NoExtField)
+     (FunBind
+      (NoExtField)
+      ({ mod185.hs:5:1-4 }
+       (Unqual
+        {OccName: main}))
+      (MG
+       (NoExtField)
+       ({ mod185.hs:5:1-24 }
+        [({ mod185.hs:5:1-24 }
+          (Match
+           (NoExtField)
+           (FunRhs
+            ({ mod185.hs:5:1-4 }
+             (Unqual
+              {OccName: main}))
+            (Prefix)
+            (NoSrcStrict))
+           []
+           (GRHSs
+            (NoExtField)
+            [({ mod185.hs:5:6-24 }
+              (GRHS
+               (NoExtField)
+               []
+               ({ mod185.hs:5:8-24 }
+                (HsVar
+                 (NoExtField)
+                 ({ mod185.hs:5:8-24 }
+                  (Qual
+                   {ModuleName: Prelude}
+                   {OccName: undefined}))))))]
+            ({ <no location info> }
+             (EmptyLocalBinds
+              (NoExtField))))))])
+       (FromSource))
+      (WpHole)
+      [])))]
+  (Nothing)
+  (Nothing)))



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb9c45a0d612f8e16a0b0abd686534fedfdbac78...0b3497ef219311a12d7bbe756fb7210cee8a2f7b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eb9c45a0d612f8e16a0b0abd686534fedfdbac78...0b3497ef219311a12d7bbe756fb7210cee8a2f7b
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201214/034cd9ef/attachment-0001.html>


More information about the ghc-commits mailing list