Do not report error if Name in pragma is unbound
authornineonine <mail4chemik@gmail.com>
Wed, 22 May 2019 04:34:27 +0000 (21:34 -0700)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Sun, 9 Jun 2019 22:45:31 +0000 (18:45 -0400)
compiler/rename/RnEnv.hs
testsuite/tests/rename/should_fail/T16610.hs [new file with mode: 0644]
testsuite/tests/rename/should_fail/T16610.stderr [new file with mode: 0644]
testsuite/tests/rename/should_fail/all.T

index 82aa508..772122b 100644 (file)
@@ -68,6 +68,7 @@ import PrelNames        ( rOOT_MAIN )
 import BasicTypes       ( pprWarningTxtForMsg, TopLevelFlag(..))
 import SrcLoc
 import Outputable
+import UniqSet          ( uniqSetAny )
 import Util
 import Maybes
 import DynFlags
@@ -1462,7 +1463,9 @@ lookupBindGroupOcc ctxt what rdr_name
       RoleAnnotCtxt ns -> lookup_top (`elemNameSet` ns)
       LocalBindCtxt ns -> lookup_group ns
       ClsDeclCtxt  cls -> lookup_cls_op cls
-      InstDeclCtxt ns  -> lookup_top (`elemNameSet` ns)
+      InstDeclCtxt ns  -> if uniqSetAny isUnboundName ns -- #16610
+                          then return (Right $ mkUnboundNameRdr rdr_name)
+                          else lookup_top (`elemNameSet` ns)
   where
     lookup_cls_op cls
       = lookupSubBndrOcc True cls doc rdr_name
diff --git a/testsuite/tests/rename/should_fail/T16610.hs b/testsuite/tests/rename/should_fail/T16610.hs
new file mode 100644 (file)
index 0000000..e8d4024
--- /dev/null
@@ -0,0 +1,6 @@
+module T16610 where
+
+data Foo = Foo
+instance Eq Foo where
+  {-# INLINE wrong #-}
+  wrong _ = True
diff --git a/testsuite/tests/rename/should_fail/T16610.stderr b/testsuite/tests/rename/should_fail/T16610.stderr
new file mode 100644 (file)
index 0000000..9f1a671
--- /dev/null
@@ -0,0 +1,3 @@
+
+T16610.hs:6:3: error:
+    ‘wrong’ is not a (visible) method of class ‘Eq’
index 28f9790..35a3174 100644 (file)
@@ -150,3 +150,4 @@ test('T15957_Fail', normal, compile_fail, ['-Werror -Wall -Wno-missing-signature
 test('T16385', normal, compile_fail, [''])
 test('T16504', normal, compile_fail, [''])
 test('T14548', normal, compile_fail, [''])
+test('T16610', normal, compile_fail, [''])