Opened 2 years ago

Closed 19 months ago

#14105 closed bug (fixed)

ApplicativeDo causes GHC panic on irrefutable list pattern match

Reported by: BoteboTsebo Owned by:
Priority: normal Milestone: 8.4.1
Component: Compiler Version: 8.2.1
Keywords: ApplicativeDo Cc:
Operating System: Unknown/Multiple Architecture: x86_64 (amd64)
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

So this just happened:

{-# language ApplicativeDo #-}
module Main where

main :: IO ()
main = do
  [_] <- pure []
  pure ()

Compiling (under Stack) with stack exec -- ghc --make src/Main.hs yields

[1 of 1] Compiling Main             ( src/Main.hs, src/Main.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.2.1 for x86_64-unknown-linux):
	isStrictPattern

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

This does not happen on GHC-8.0.2. It does not happen when ApplicativeDo is not activated. It also does not happen when the pattern match line is changed to

  [] <- pure []

For completeness, the compiler used by stack is that which comes with nightly-2017-08-10. I am on Linux x64 (Ubuntu).

Change History (11)

comment:1 Changed 2 years ago by alexbiehl

This is most likely due to a missing case for ListPat in isStrictPattern.

comment:2 Changed 2 years ago by BoteboTsebo

Type of failure: None/UnknownCompile-time crash or panic

comment:3 Changed 2 years ago by Ben Gamari <ben@…>

In 03327bf/ghc:

Handle ListPat in isStrictPattern

This fixes #14105.

comment:4 Changed 2 years ago by simonpj

So can we add a test case and close (Ben)?

comment:5 Changed 22 months ago by lippling

I think this is not fixed completely. With 8.2.2 I get:

[62 of 63] Compiling Handler.Arena    ( Handler/Arena.hs, .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/Handler/Arena.o )
    ghc: panic! (the 'impossible' happened)
      (GHC version 8.2.2 for x86_64-apple-darwin):
    	isStrictPattern
    
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Disabling ApplicativeDo helps. I don't know what triggers it, yet. If you need to know, I'll try to find a minimal example.

comment:6 Changed 22 months ago by simonpj

Ugh. Yes a minimal test case would be super helpful. Thanks

comment:7 Changed 22 months ago by BoteboTsebo

@lippling I believe it is still broken in 8.2.2 since it hasn't been merged in, since it lacks a test case.

I am not sure how test cases work in GHC, thus I don't have the confidence that I could create one myself. I'll look around for a few fixed bugs and see how their test cases were structured, and hopefully (very unlikely with my current knowledge) come up with a commit or two to complete this fix.

Last edited 22 months ago by BoteboTsebo (previous) (diff)

comment:8 Changed 21 months ago by lippling

Ok, I found a minimal example:

{-# LANGUAGE ApplicativeDo #-}

x = do
    [_] <- undefined -- the list is the problem
    undefined

comment:9 Changed 21 months ago by simonpj

Works fine in HEAD. Perhaps the patch didn't get merged into 8.2? Ben?

comment:10 Changed 21 months ago by bgamari

Milestone: 8.2.3
Status: newmerge

Indeed it looks like this sadly fell through the cracks.

comment:11 Changed 19 months ago by bgamari

Milestone: 8.2.38.4.1
Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.