Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#2033 closed bug (fixed)

GHC-6.9 panics rather than parse error, related to view patterns.

Reported by: apeacock Owned by: igloo
Priority: normal Milestone: 6.10 branch
Component: Compiler Version: 6.9
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Test Case: rnfail051
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

Try to compile the below program, ghc panics rather than giving a parse error (in the program I was trying to write, wrapper's argument should be a lambda function).

main = do

wrapper (_ -> putStrLn "_")

wrapper :: (String -> IO ()) -> IO () wrapper f = f ""

Output:

[1 of 1] Compiling Main ( Test.hs, interpreted ) : panic! (the 'impossible' happened)

(GHC version 6.9.20071111 for i386-unknown-mingw32):

rnExpr: unexpected expression: panic! (the 'impossible' happened)

(GHC version 6.9.20071111 for i386-unknown-mingw32):

hsSyn/HsExpr.lhs:(320,0)-(467,72): Non-exhaustive patterns in functi

pr_expr

Change History (8)

comment:1 Changed 8 years ago by apeacock

Sorry, hit submit rather than preview, here is the code again:

main = do
    wrapper (_ -> putStrLn "_")

wrapper :: (String -> IO ()) -> IO ()
wrapper f = f ""

Output

[1 of 1] Compiling Main             ( Test.hs, interpreted )
: panic! (the 'impossible' happened)
  (GHC version 6.9.20071111 for i386-unknown-mingw32):
        rnExpr: unexpected expression: panic! (the 'impossible' happened)
  (GHC version 6.9.20071111 for i386-unknown-mingw32):
        hsSyn/HsExpr.lhs:(320,0)-(467,72): Non-exhaustive patterns in functi
pr_expr

comment:2 Changed 8 years ago by igloo

  • Owner set to igloo

comment:3 Changed 8 years ago by igloo

  • Milestone set to 6.10 branch
  • Owner igloo deleted

I've fixed half of this, so now we get:

ghc-6.9.20080112: panic! (the 'impossible' happened)
  (GHC version 6.9.20080112 for x86_64-unknown-linux):
   rnExpr: unexpected expression _ -> putStrLn{v} "_"

comment:4 Changed 8 years ago by simonpj

Ian, I guess you understand what is going on here? Patterns are parsed as expressions, and then converted to patterns. The form (e -> p), the EViewPat constructor in HsExpr, is valid as a pattern, but not as as expression. Just like EWildPat, EAsPat, ELazyPat.

The renamer checks for these (line 280 of RnExpr), so it's just a qn of adding EViewPat there too. The error message isn't fantastic, but it's better than a crash.

I'll let you finish this since you've started.

Simon

comment:5 Changed 8 years ago by igloo

  • Owner set to igloo

comment:6 Changed 8 years ago by igloo

  • Architecture changed from x86 to Multiple
  • Operating System changed from Windows to Multiple
  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to rnfail051

Simon, yes, I had guessed that it ought to be rejected earlier, but hadn't looked for where yet. Now fixed - thanks for the pointer!

Thanks Ian

comment:7 Changed 7 years ago by simonmar

  • Architecture changed from Multiple to Unknown/Multiple

comment:8 Changed 7 years ago by simonmar

  • Operating System changed from Multiple to Unknown/Multiple
Note: See TracTickets for help on using tickets.