[Git][ghc/ghc][wip/expand-do] fixing DoExpanion2 test

Apoorv Ingle (@ani) gitlab at gitlab.haskell.org
Thu Jul 27 00:40:38 UTC 2023



Apoorv Ingle pushed to branch wip/expand-do at Glasgow Haskell Compiler / GHC


Commits:
ac4d0665 by Apoorv Ingle at 2023-07-26T19:40:23-05:00
fixing DoExpanion2 test

- - - - -


2 changed files:

- compiler/GHC/Tc/Gen/App.hs
- testsuite/tests/typecheck/should_fail/DoExpansion2.stderr


Changes:

=====================================
compiler/GHC/Tc/Gen/App.hs
=====================================
@@ -567,7 +567,13 @@ tcInstFun do_ql inst_final (tc_fun, fun_ctxt) fun_sigma rn_args
     fun_orig = case fun_ctxt of
                  VAExpansionStmt{} -> DoOrigin
                  VAExpansion e _ -> exprCtOrigin e
-                 VACall e _ _    -> exprCtOrigin e
+                 VACall e _ _
+                   | HsVar _ (L _ fun_id) <- tc_fun
+                   , fun_id `hasKey` failMClassOpKey
+                   , isGeneratedSrcSpan (appCtxtLoc fun_ctxt)
+                   -> DoOrigin -- Ideally i want the pattern here that is failable but thats in another branch
+                   | otherwise
+                   -> exprCtOrigin e
 
     -- These are the type variables which must be instantiated to concrete
     -- types. See Note [Representation-polymorphic Ids with no binding]
@@ -582,11 +588,6 @@ tcInstFun do_ql inst_final (tc_fun, fun_ctxt) fun_sigma rn_args
       | otherwise
       = noConcreteTyVars
 
-    -- isFailFun
-    --   | HsVar _ (L _ fun_id) <- tc_fun
-    --   , fun_id `hasKey` failMClassOpKey
-    --   , isGeneratedSrcSpan (appCtxtLoc fun_ctxt)
-
     -- Count value args only when complaining about a function
     -- applied to too many value args
     -- See Note [Herald for matchExpectedFunTys] in GHC.Tc.Utils.Unify.


=====================================
testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
=====================================
@@ -11,10 +11,9 @@ DoExpansion2.hs:16:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul
         Actual: String
     • In the first argument of ‘return’, namely ‘x’
       In a stmt of a 'do' block: return x
-      In an equation for ‘ffff2’:
-          ffff2
-            = do x <- (getVal 3)
-                 return x
+      In the expression:
+        do x <- (getVal 3)
+           return x
 
 DoExpansion2.hs:20:20: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
     • Couldn't match expected type ‘Int’ with actual type ‘Char’
@@ -40,20 +39,18 @@ DoExpansion2.hs:27:12: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul
     • Couldn't match expected type ‘Char’ with actual type ‘Maybe Int’
     • In the pattern: Just x
       In a stmt of a 'do' block: Just x <- getChar
-      In an equation for ‘ffff5’:
-          ffff5
-            = do x <- getChar
-                 Just x <- getChar
-                 return x
+      In the expression:
+        do x <- getChar
+           Just x <- getChar
+           return x
 
 DoExpansion2.hs:31:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
     • Couldn't match expected type ‘Int’ with actual type ‘()’
     • In the first argument of ‘return’, namely ‘()’
       In a stmt of a 'do' block: return ()
-      In an equation for ‘ffff6’:
-          ffff6
-            = do _ <- (getVal 1)
-                 return ()
+      In the expression:
+        do _ <- (getVal 1)
+           return ()
 
 DoExpansion2.hs:34:22: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
     • Couldn't match expected type: t0 -> IO (Maybe Int)
@@ -71,7 +68,6 @@ DoExpansion2.hs:39:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul
         Actual: String
     • In the first argument of ‘return’, namely ‘x’
       In a stmt of a 'do' block: return x
-      In an equation for ‘ffff8’:
-          ffff8
-            = do x <- getVal 3
-                 return x
+      In the expression:
+        do x <- getVal 3
+           return x



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac4d0665fee2cee3108fcf1ef814c5631b67da35

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ac4d0665fee2cee3108fcf1ef814c5631b67da35
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230726/0fb6ab4f/attachment-0001.html>


More information about the ghc-commits mailing list