Commit 9f9345e5 authored by kaiha's avatar kaiha Committed by Ben Gamari
Browse files

Create empty dump files (fixes #10320)

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #10320
parent 6c2c853b
......@@ -1581,7 +1581,9 @@ tryRules env rules fn args call_cont
= do { dflags <- getDynFlags
; case lookupRule dflags (getUnfoldingInRuleMatch env) (activeRule env)
fn (argInfoAppArgs args) rules of {
Nothing -> return Nothing ; -- No rule matches
Nothing ->
do { nodump dflags -- This ensures that an empty file is written
; return Nothing } ; -- No rule matches
Just (rule, rule_rhs) ->
do { checkedTick (RuleFired (ru_name rule))
; let cont' = pushSimplifiedArgs env
......@@ -1606,6 +1608,16 @@ tryRules env rules fn args call_cont
| otherwise
= return ()
nodump dflags
| dopt Opt_D_dump_rule_rewrites dflags
= liftIO $ dumpSDoc dflags alwaysQualify Opt_D_dump_rule_rewrites "" empty
| dopt Opt_D_dump_rule_firings dflags
= liftIO $ dumpSDoc dflags alwaysQualify Opt_D_dump_rule_firings "" empty
| otherwise
= return ()
log_rule dflags flag hdr details
= liftIO . dumpSDoc dflags alwaysQualify flag "" $
sep [text hdr, nest 4 details]
......
......@@ -609,3 +609,11 @@ T10182:
"$(TEST_HC)" $(TEST_HC_OPTS) -c T10182.hs-boot
"$(TEST_HC)" $(TEST_HC_OPTS) -c T10182a.hs
"$(TEST_HC)" $(TEST_HC_OPTS) -c T10182.hs
.PHONY: T10320
T10320:
$(RM) -rf T10320 T10320.dump-rule-rewrites T10320.hi T10320.o
"$(TEST_HC)" $(TEST_HC_OPTS) -ddump-to-file -ddump-rule-rewrites -fenable-rewrite-rules T10320.hs
[ -s T10320.dump-rule-rewrites ]
"$(TEST_HC)" $(TEST_HC_OPTS) -ddump-to-file -ddump-rule-rewrites T10320.hs
[ -f T10320.dump-rule-rewrites ] && [ ! -s T10320.dump-rule-rewrites ]
-- | Test file for issue #10320.
module Main (main) where
main :: IO ()
main = print $ map (+1) (map (+1) [1, 2, 3])
{-# RULES "map/map" forall f g xs. map f (map g xs) = map (f.g) xs #-}
......@@ -472,3 +472,8 @@ test('T11429a', normal, compile, ['-Wunrecognised-warning-flags -Wfoobar'])
test('T11429b', normal, compile, ['-Wno-unrecognised-warning-flags -Wfoobar'])
test('T11429c', normal, compile_fail, ['-Wunrecognised-warning-flags -Werror -Wfoobar'])
test('T10320',
[ ignore_output
, extra_clean(['T10320', 'T10320.o', 'T10320.hi'])],
run_command,
['$MAKE -s --no-print-directory T10320'])
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