[Git][ghc/ghc][cherry-pick-43a43a33] 2 commits: Fix optSemi type in Parser.y

Ben Gamari gitlab at gitlab.haskell.org
Tue Jun 4 03:42:29 UTC 2019



Ben Gamari pushed to branch cherry-pick-43a43a33 at Glasgow Haskell Compiler / GHC


Commits:
605869c7 by Vladislav Zavialov at 2019-06-03T21:28:12Z
Fix optSemi type in Parser.y

The definition of 'optSemi' claimed it had type

([Located a],Bool)

Note that its production actually returns ([Located Token],Bool):

  : ';' { ([$1],True) }   -- $1 :: Located Token

Due to an infelicity in the implementation of 'happy -c', it effectively
resulted in 'unsafeCoerce :: Token -> a'.
See https://github.com/simonmar/happy/pull/134

If any consumer of 'optSemi' tried to instantiate 'a' to something not
representationally equal to 'Token', they would experience a segfault.

In addition to that, this definition made it impossible to compile Parser.y
without the -c flag (as it's reliant on this bug to cast 'Token' to 'forall
a. a').

- - - - -
0b91a029 by Krzysztof Gogolewski at 2019-06-04T03:42:27Z
Handle hs-boot files in -Wmissing-home-modules (#16551)


(cherry picked from commit 43a43a3319d68c1692df6acdf283109cb5c030d8)
- - - - -


7 changed files:

- compiler/main/GhcMake.hs
- compiler/parser/Parser.y
- + testsuite/tests/warnings/should_compile/T16551.stderr
- + testsuite/tests/warnings/should_compile/T16551/A.hs
- + testsuite/tests/warnings/should_compile/T16551/B.hs
- + testsuite/tests/warnings/should_compile/T16551/B.hs-boot
- testsuite/tests/warnings/should_compile/all.T


Changes:

=====================================
compiler/main/GhcMake.hs
=====================================
@@ -184,6 +184,10 @@ warnMissingHomeModules hsc_env mod_graph =
     is_my_target mod (TargetFile target_file _)
       | Just mod_file <- ml_hs_file (ms_location mod)
       = target_file == mod_file ||
+
+           --  Don't warn on B.hs-boot if B.hs is specified (#16551)
+           addBootSuffix target_file == mod_file ||
+
            --  We can get a file target even if a module name was
            --  originally specified in a command line because it can
            --  be converted in guessTarget (by appending .hs/.lhs).


=====================================
compiler/parser/Parser.y
=====================================
@@ -1,4 +1,3 @@
-
 --                                                              -*-haskell-*-
 -- ---------------------------------------------------------------------------
 -- (c) The University of Glasgow 1997-2003
@@ -2586,7 +2585,7 @@ exp10 :: { LHsExpr GhcPs }
         | scc_annot exp        {% ams (sLL $1 $> $ HsSCC noExt (snd $ fst $ unLoc $1) (snd $ unLoc $1) $2)
                                       (fst $ fst $ unLoc $1) }
 
-optSemi :: { ([Located a],Bool) }
+optSemi :: { ([Located Token],Bool) }
         : ';'         { ([$1],True) }
         | {- empty -} { ([],False) }
 


=====================================
testsuite/tests/warnings/should_compile/T16551.stderr
=====================================
@@ -0,0 +1,3 @@
+[1 of 3] Compiling B[boot]          ( T16551/B.hs-boot, T16551/B.o-boot )
+[2 of 3] Compiling A                ( T16551/A.hs, T16551/A.o )
+[3 of 3] Compiling B                ( T16551/B.hs, T16551/B.o )


=====================================
testsuite/tests/warnings/should_compile/T16551/A.hs
=====================================
@@ -0,0 +1,2 @@
+module A where
+import {-# SOURCE #-} B


=====================================
testsuite/tests/warnings/should_compile/T16551/B.hs
=====================================
@@ -0,0 +1,2 @@
+module B where
+import A


=====================================
testsuite/tests/warnings/should_compile/T16551/B.hs-boot
=====================================
@@ -0,0 +1 @@
+module B where


=====================================
testsuite/tests/warnings/should_compile/all.T
=====================================
@@ -22,6 +22,7 @@ test('Werror01', normal, compile, [''])
 test('Werror02', normal, compile, [''])
 
 test('MissingMod', normal, multimod_compile, ['MissingMod', '-Wmissing-home-modules'])
+test('T16551', [extra_files(['T16551/'])], multimod_compile, ['T16551/A.hs T16551/B.hs', '-Wmissing-home-modules'])
 
 test('StarBinder', normal, compile, [''])
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/d5ff2c3a702944e89550f4832bf46e25bebd7b3c...0b91a0292b63fbe7f620b6b005efa480d20adb3e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/compare/d5ff2c3a702944e89550f4832bf46e25bebd7b3c...0b91a0292b63fbe7f620b6b005efa480d20adb3e
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/20190603/730bdbd4/attachment-0001.html>


More information about the ghc-commits mailing list