
#11651: Allow plugins to define built-in rules -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: merge Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- @@ -1,2 +1,2 @@ - Conal Eliot has an application in which he wants a plugin to add some new - `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being + Conal Elliott has an application in which he wants a plugin to add some + new `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being New description: Conal Elliott has an application in which he wants a plugin to add some new `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being compiled. He needs a built-in rule (which runs some custom code) rather than a vanilla `CoreRule` (which pattern-matches the argument). But then he got a GHC panic {{{ get a GHC panic: “No match in record selector ru_args”. }}} Turns out it comes from these lines in `OccAnal` {{{ imp_rule_edges = foldr (plusVarEnv_C unionVarSet) emptyVarEnv [ mapVarEnv (const maps_to) (exprFreeIds arg `delVarSetList` ru_bndrs imp_rule) | imp_rule <- imp_rules , let maps_to = exprFreeIds (ru_rhs imp_rule) `delVarSetList` ru_bndrs imp_rule , arg <- ru_args imp_rule ] }}} This code is just working out what locally-defined variables should be kept alive by the `mg_rules` for imported Ids. But `BuiltinRules` don't have any `ru_args`. Easy fix: just don't traverse builtin rules in this scan. In Conal's case, the rules that his plugin adds certainly don't mention locally- defined Ids. I'll do this shortly. -- Comment (by conal): Fixed spelling of my last name. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11651#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler