Opened 9 months ago

Closed 5 weeks ago

#14471 closed bug (fixed)

Certain do blocks cause TH to barf when ApplicativeDo is enabled

Reported by: lexi.lambda Owned by: mgsloan
Priority: normal Milestone: 8.6.1
Component: Template Haskell Version: 8.2.1
Keywords: ApplicativeDo Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case: th/T14471
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D4912
Wiki Page:

Description

The following program fails with an error:

{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE TemplateHaskell #-}

main = $([|do
  return ()
  return ()
  return ()|])
Exotic.hs:4:12: error:
    Exotic statement not (yet) handled by Template Haskell
      [return ();
       return (),
       return ()]

It only happens when ApplicativeDo is enabled.

Furthermore, while this example is extremely minimal, this issue isn’t restricted to ApplicativeDo’s special handling of return. The following example produces the same error:

{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE TemplateHaskell #-}

main = $([|do
  getLine
  getLine
  getLine|])
Exotic.hs:4:12: error:
    Exotic statement not (yet) handled by Template Haskell
      [getLine;
       getLine,
       getLine]

This doesn’t happen with fewer than three statements in the do block, but it does happen with more.

Change History (5)

comment:1 Changed 8 months ago by lexi.lambda

Keywords: ApplicativeDo added

comment:2 Changed 7 weeks ago by mgsloan

Differential Rev(s): Phab:D4912
Owner: set to mgsloan

comment:3 Changed 7 weeks ago by mgsloan

Status: newpatch
Test Case: th/T14471

comment:4 Changed 5 weeks ago by Ben Gamari <ben@…>

In 234093cf/ghc:

Fix handling of ApplicativeDo in TH AST quotes

See https://ghc.haskell.org/trac/ghc/ticket/14471

Also fixes a parenthesization bug in pprStmt when ret_stripped is True

Test Plan: tests added to testsuite

Trac issues: #14471

Reviewers: goldfire, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4912

comment:5 Changed 5 weeks ago by bgamari

Milestone: 8.6.1
Resolution: fixed
Status: patchclosed
Note: See TracTickets for help on using tickets.