Omit the static form error for variables not in scope.
authorFacundo Domínguez <facundo.dominguez@tweag.io>
Tue, 26 May 2015 02:08:05 +0000 (21:08 -0500)
committerAustin Seipp <austin@well-typed.com>
Tue, 26 May 2015 02:08:05 +0000 (21:08 -0500)
Summary:
Fixes T10446.

The following program

> g = static f

now produces only:

> ...: error
>    Not in scope: 'f'

Before it would also produce a complaint about 'f' not being a top-level
identifier.

Test Plan: validate

Reviewers: austin

Reviewed By: austin

Subscribers: bgamari, thomie, mboes

Differential Revision: https://phabricator.haskell.org/D906

GHC Trac Issues: #10446

compiler/rename/RnExpr.hs
testsuite/tests/rename/should_fail/RnStaticPointersFail02.stderr

index 50860f9..71fa1cb 100644 (file)
@@ -330,7 +330,9 @@ rnExpr e@(HsStatic expr) = do
              ]
       _ -> do
        let isTopLevelName n = isExternalName n || isWiredInName n
-       case nameSetElems $ filterNameSet (not . isTopLevelName) fvExpr of
+       case nameSetElems $ filterNameSet
+                             (\n -> not (isTopLevelName n || isUnboundName n))
+                             fvExpr                                           of
          [] -> return ()
          fvNonGlobal -> addErr $ cat
              [ text $ "Only identifiers of top-level bindings can "
index 6524702..52e3609 100644 (file)
@@ -1,8 +1,3 @@
 
-RnStaticPointersFail02.hs:5:5:
-    Only identifiers of top-level bindings can appear in the body of the static form:
-      static T
-    but the following identifiers were found instead:
-      T
-
-RnStaticPointersFail02.hs:5:12: Not in scope: data constructor ‘T’
+RnStaticPointersFail02.hs:5:12: error:
+    Not in scope: data constructor ‘T’