From 4f9d6008c04b71fc9449b3dc10861f757539ed0f Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Wed, 8 Jul 2015 23:42:28 +0100 Subject: Fix Trac #10618 (out of scope operator) Out of scope variables now generate HsUnboundVar, and the fixity re-jigging wasn't taking this into account. --- compiler/rename/RnTypes.hs | 7 +++++-- testsuite/tests/rename/should_fail/T10618.hs | 3 +++ testsuite/tests/rename/should_fail/T10618.stderr | 6 ++++++ testsuite/tests/rename/should_fail/all.T | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 testsuite/tests/rename/should_fail/T10618.hs create mode 100644 testsuite/tests/rename/should_fail/T10618.stderr diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs index 705ca557d4..ac2982ba4f 100644 --- a/compiler/rename/RnTypes.hs +++ b/compiler/rename/RnTypes.hs @@ -829,8 +829,11 @@ mkOpAppRn e1 op fix e2 -- Default case, no rearrangment ---------------------------- get_op :: LHsExpr Name -> Name -get_op (L _ (HsVar n)) = n -get_op other = pprPanic "get_op" (ppr other) +-- An unbound name could be either HsVar or HsUnboundVra +-- See RnExpr.rnUnboundVar +get_op (L _ (HsVar n)) = n +get_op (L _ (HsUnboundVar occ)) = mkUnboundName (mkRdrUnqual occ) +get_op other = pprPanic "get_op" (ppr other) -- Parser left-associates everything, but -- derived instances may have correctly-associated things to diff --git a/testsuite/tests/rename/should_fail/T10618.hs b/testsuite/tests/rename/should_fail/T10618.hs new file mode 100644 index 0000000000..28b665f6fb --- /dev/null +++ b/testsuite/tests/rename/should_fail/T10618.hs @@ -0,0 +1,3 @@ +module T10618 where + +foo = Just $ Nothing <> Nothing diff --git a/testsuite/tests/rename/should_fail/T10618.stderr b/testsuite/tests/rename/should_fail/T10618.stderr new file mode 100644 index 0000000000..01e194877f --- /dev/null +++ b/testsuite/tests/rename/should_fail/T10618.stderr @@ -0,0 +1,6 @@ + +T10618.hs:3:22: error: + Variable not in scope: (<>) :: Maybe (Maybe a0) -> Maybe a1 -> t + Perhaps you meant one of these: + ‘<$>’ (imported from Prelude), ‘*>’ (imported from Prelude), + ‘<$’ (imported from Prelude) diff --git a/testsuite/tests/rename/should_fail/all.T b/testsuite/tests/rename/should_fail/all.T index 0df986889d..bfd81c51f9 100644 --- a/testsuite/tests/rename/should_fail/all.T +++ b/testsuite/tests/rename/should_fail/all.T @@ -133,3 +133,4 @@ test('T9032', normal, run_command, ['$MAKE -s --no-print-directory T9032']) +test('T10618', normal, compile_fail, ['']) -- cgit v1.2.1