diff options
author | Dr. ERDI Gergo <gergo@erdi.hu> | 2014-11-08 12:24:55 +0800 |
---|---|---|
committer | Dr. ERDI Gergo <gergo@erdi.hu> | 2014-11-08 14:02:19 +0800 |
commit | 474e535b6b121809a8d75df5a4c37dc574d3d302 (patch) | |
tree | 06bbc854a0062c2d8fe59e02dcadda166e8f0327 /testsuite/tests/patsyn | |
parent | f5996d9106f5b6b12e52ad93256233fc1cc459c9 (diff) | |
download | haskell-474e535b6b121809a8d75df5a4c37dc574d3d302.tar.gz |
In pattern synonym matchers, support unboxed continuation results (fixes #9783).
This requires ensuring the continuations have arguments by adding a dummy
Void# argument when needed. This is so that matching on a pattern synonym
is lazy even when the result is unboxed, e.g.
pattern P = ()
f P = 0#
In this case, without dummy arguments, the generated matcher's type would be
$mP :: forall (r :: ?). () -> r -> r -> r
which is called in `f` at type `() -> Int# -> Int# -> Int#`,
so it would be strict, in particular, in the failure continuation
of `patError`.
We work around this by making sure both continuations have arguments:
$mP :: forall (r :: ?). () -> (Void# -> r) -> (Void# -> r) -> r
Of course, if `P` (and thus, the success continuation) has any arguments,
we are only adding the extra dummy argument to the failure continuation.
Diffstat (limited to 'testsuite/tests/patsyn')
-rw-r--r-- | testsuite/tests/patsyn/should_run/T9783.hs | 15 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_run/T9783.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/patsyn/should_run/all.T | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/testsuite/tests/patsyn/should_run/T9783.hs b/testsuite/tests/patsyn/should_run/T9783.hs new file mode 100644 index 0000000000..daef96032b --- /dev/null +++ b/testsuite/tests/patsyn/should_run/T9783.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE PatternSynonyms, MagicHash #-} +module Main where + +import GHC.Base + +pattern P1 <- 0 +pattern P2 <- 1 + +f :: Int -> Int# +f P1 = 42# +f P2 = 44# + +main = do + print $ I# (f 0) + print $ I# (f 1) diff --git a/testsuite/tests/patsyn/should_run/T9783.stdout b/testsuite/tests/patsyn/should_run/T9783.stdout new file mode 100644 index 0000000000..c26b130d29 --- /dev/null +++ b/testsuite/tests/patsyn/should_run/T9783.stdout @@ -0,0 +1,2 @@ +42 +44 diff --git a/testsuite/tests/patsyn/should_run/all.T b/testsuite/tests/patsyn/should_run/all.T index b3c6b74461..9c3f16b0ea 100644 --- a/testsuite/tests/patsyn/should_run/all.T +++ b/testsuite/tests/patsyn/should_run/all.T @@ -3,3 +3,4 @@ test('match', normal, compile_and_run, ['']) test('ex-prov-run', normal, compile_and_run, ['']) test('bidir-explicit', normal, compile_and_run, ['']) test('bidir-explicit-scope', normal, compile_and_run, ['']) +test('T9783', normal, compile_and_run, ['']) |