Commit 36e8bcba authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

HsPat: Assume that no spliced patterns are irrefutable

This is a conservative assumption which will limit some uses of spliced
patterns, but it fixes #13984.

Test Plan: Validate

Reviewers: RyanGlScott, AaronFriel, austin

Reviewed By: RyanGlScott

Subscribers: rwbarton, thomie

GHC Trac Issues: #13984

Differential Revision: https://phabricator.haskell.org/D3766
parent ccac387b
......@@ -636,11 +636,9 @@ isIrrefutableHsPat pat
go1 (NPat {}) = False
go1 (NPlusKPat {}) = False
-- Both should be gotten rid of by renamer before
-- isIrrefutablePat is called
go1 (SplicePat {}) = urk pat
urk pat = pprPanic "isIrrefutableHsPat:" (ppr pat)
-- We conservatively assume that no TH splices are irrefutable
-- since we cannot know until the splice is evaluated.
go1 (SplicePat {}) = False
hsPatNeedsParens :: Pat a -> Bool
hsPatNeedsParens (NPlusKPat {}) = True
......
{-# LANGUAGE TemplateHaskell #-}
module Panic where
import Language.Haskell.TH
expr :: IO Exp
expr = runQ $ do
name <- newName "foo"
[| do $(varP name) <- pure (); pure () |]
......@@ -570,3 +570,4 @@ test('T13879', normal, compile, [''])
test('T13881', normal, compile, [''])
test('T13915a', normal, multimod_compile, ['T13915a', '-v0'])
test('T13915b', normal, compile, [''])
test('T13984', normal, compile, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment