diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2016-09-16 22:33:20 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2016-09-30 12:53:20 +0100 |
commit | 2fbfbca2d12a8e9a09627529cf4f8284b19023ff (patch) | |
tree | 2c5b345ebc9d46e45488ace751f554f154ffafd6 /testsuite | |
parent | 0b533a2597a8c5d5b623a008378af39826b009db (diff) | |
download | haskell-2fbfbca2d12a8e9a09627529cf4f8284b19023ff.tar.gz |
Fix desugaring of pattern bindings (again)
This patch fixes Trac #12595. The problem was with a
pattern binding like
!x = e
For a start it's silly to match that pattern and build
a unit tuple (the General Case of mkSelectorBinds); but
that's what was happening because the bang fell through
to the general case. But for a variable pattern building
any auxiliary bindings is stupid. So the patch
introduces a new case in mkSelectorBinds for variable
patterns.
Then it turned out that if 'e' was a plain variable, and
moreover was imported GlobalId, then matchSinglePat made
it a /bound/ variable, which should never happen. That
ultimately caused a linker error, but the original bug
was much earlier.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/deSugar/should_run/T12595.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/deSugar/should_run/T12595.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/deSugar/should_run/all.T | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/testsuite/tests/deSugar/should_run/T12595.hs b/testsuite/tests/deSugar/should_run/T12595.hs new file mode 100644 index 0000000000..86e0419f65 --- /dev/null +++ b/testsuite/tests/deSugar/should_run/T12595.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE BangPatterns #-} +module Main where + +import GHC.Base + +-- In Trac #12595 a bogus desugaring led (bizarrely) +-- to a top-level binding maxInt = maxInt +-- This test just checks that doesn't happen again + +main = print (let !x = maxInt in even x) diff --git a/testsuite/tests/deSugar/should_run/T12595.stdout b/testsuite/tests/deSugar/should_run/T12595.stdout new file mode 100644 index 0000000000..bc59c12aa1 --- /dev/null +++ b/testsuite/tests/deSugar/should_run/T12595.stdout @@ -0,0 +1 @@ +False diff --git a/testsuite/tests/deSugar/should_run/all.T b/testsuite/tests/deSugar/should_run/all.T index fce86c51c3..abbef91735 100644 --- a/testsuite/tests/deSugar/should_run/all.T +++ b/testsuite/tests/deSugar/should_run/all.T @@ -59,3 +59,4 @@ test('T11193', exit_code(1), compile_and_run, ['']) test('T11572', exit_code(1), compile_and_run, ['']) test('T11601', exit_code(1), compile_and_run, ['']) test('T11747', normal, compile_and_run, ['-dcore-lint']) +test('T12595', normal, compile_and_run, ['']) |