
#15321: Typed holes in Template Haskell splices produce bewildering error messages -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.4.3 Resolution: | Keywords: TypedHoles Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * differential: Phab:D4907 => Comment: You're right. In `TcHoleErrors` we see {{{ lookup :: Either Id GlobalRdrElt -> TcM (Maybe Id) lookup (Left id) = return $ Just id lookup (Right el) = do { thing <- tcLookup (gre_name el) ; case thing of }}} That call to `tcLookup` checks for staging errors (it calls `tcLookupGlobal` which calls `notFound`). Easiest solution: something like {{{ lookup (Right el) = tryTcDiscardingErrs (return Nothing) $ do { thing <- tcLookup (gre_name el) ; case thing of }}} The `tryTcDiscardingErrs` does what it sounds like. It's not super-efficient, but it doesn't have to be ... this is in error- message generation only. It needs a `Note` to explain why the lookup can fail. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15321#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler