Commit 48222831 authored by thomasw's avatar thomasw Committed by Austin Seipp

Fix panic on [t| _ |] (Trac #9879)

Summary:
Type brackets containing a wildcard, e.g. `[t| _ |]`, caused a panic.
Fix it by disallowing wildcards in type brackets.

Together with D572, this fixes #9879.

Test Plan: new test WildcardInTypeBrackets should pass

Reviewers: austin

Reviewed By: austin

Subscribers: carter, thomie, monoidal

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

GHC Trac Issues: #9879
parent bd0f9e1f
......@@ -2081,7 +2081,10 @@ aexp2 :: { LHsExpr RdrName }
| TH_TY_QUOTE gtycon { sLL $1 $> $ HsBracket (VarBr False (unLoc $2)) }
| '[|' exp '|]' {% ams (sLL $1 $> $ HsBracket (ExpBr $2)) [mo $1,mc $3] }
| '[||' exp '||]' {% ams (sLL $1 $> $ HsBracket (TExpBr $2)) [mo $1,mc $3]}
| '[t|' ctype '|]' {% ams (sLL $1 $> $ HsBracket (TypBr $2)) [mo $1,mc $3] }
| '[t|' ctype '|]' {% checkNoPartialType
(text "in type brackets" <> colon
<+> quotes (text "[t|" <+> ppr $2 <+> text "|]")) $2 >>
ams (sLL $1 $> $ HsBracket (TypBr $2)) [mo $1,mc $3] }
| '[p|' infixexp '|]' {% checkPattern empty $2 >>= \p ->
ams (sLL $1 $> $ HsBracket (PatBr p))
[mo $1,mc $3] }
......
{-# LANGUAGE TemplateHaskell #-}
module WildcardInTypeBrackets where
foo = [t| _ |]
WildcardInTypeBrackets.hs:4:11:
Wildcard not allowed
in type brackets: ‘[t| _ |]’
......@@ -36,6 +36,7 @@ test('WildcardsInPatternAndExprSig', normal, compile_fail, [''])
test('WildcardInPatSynSig', normal, compile_fail, [''])
test('WildcardInNewtype', normal, compile_fail, [''])
test('WildcardInstantiations', normal, compile_fail, [''])
test('WildcardInTypeBrackets', [req_interp, only_compiler_types(['ghc'])], compile_fail, [''])
test('WildcardInTypeFamilyInstanceLHS', normal, compile_fail, [''])
test('WildcardInTypeFamilyInstanceRHS', normal, compile_fail, [''])
test('WildcardInTypeSynonymLHS', normal, compile_fail, [''])
......
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