Fix Trac #10618 (out of scope operator)
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 8 Jul 2015 22:42:28 +0000 (23:42 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 8 Jul 2015 22:42:28 +0000 (23:42 +0100)
Out of scope variables now generate HsUnboundVar,
and the fixity re-jigging wasn't taking this into
account.

compiler/rename/RnTypes.hs
testsuite/tests/rename/should_fail/T10618.hs [new file with mode: 0644]
testsuite/tests/rename/should_fail/T10618.stderr [new file with mode: 0644]
testsuite/tests/rename/should_fail/all.T

index 705ca55..ac2982b 100644 (file)
@@ -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 (file)
index 0000000..28b665f
--- /dev/null
@@ -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 (file)
index 0000000..01e1948
--- /dev/null
@@ -0,0 +1,6 @@
+\r
+T10618.hs:3:22: error:\r
+    Variable not in scope: (<>) :: Maybe (Maybe a0) -> Maybe a1 -> t\r
+    Perhaps you meant one of these:\r
+      ‘<$>’ (imported from Prelude), ‘*>’ (imported from Prelude),\r
+      ‘<$’ (imported from Prelude)\r
index 0df9868..bfd81c5 100644 (file)
@@ -133,3 +133,4 @@ test('T9032',
      normal,
      run_command,
      ['$MAKE -s --no-print-directory T9032'])
+test('T10618', normal, compile_fail, [''])