Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC Commits: eb739088 by Apoorv Ingle at 2026-01-18T22:30:54-06:00 overwrite errctxt only when do statements are involved - - - - - 4 changed files: - compiler/GHC/Tc/Types/LclEnv.hs - testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr - testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr - testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr Changes: ===================================== compiler/GHC/Tc/Types/LclEnv.hs ===================================== @@ -212,8 +212,8 @@ setLclEnvSrcCodeOrigin ec = modifyLclCtxt (setLclCtxtSrcCodeOrigin ec) -- See Note [ErrCtxtStack Manipulation] setLclCtxtSrcCodeOrigin :: ErrCtxt -> TcLclCtxt -> TcLclCtxt setLclCtxtSrcCodeOrigin ec lclCtxt - | MkErrCtxt (ExpansionCodeCtxt _) _ : ecs <- tcl_err_ctxt lclCtxt - , MkErrCtxt (ExpansionCodeCtxt _) _ <- ec + | MkErrCtxt (ExpansionCodeCtxt OrigStmt{}) _ : ecs <- tcl_err_ctxt lclCtxt + , MkErrCtxt (ExpansionCodeCtxt OrigStmt{}) _ <- ec = lclCtxt { tcl_err_ctxt = ec : ecs } | otherwise = lclCtxt { tcl_err_ctxt = ec : tcl_err_ctxt lclCtxt } ===================================== testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr ===================================== @@ -4,13 +4,9 @@ RecordDotSyntaxFail10.hs:40:11: error: [GHC-39999] NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class. Insoluble functional dependencies wrt top-level instances • In the second argument of ‘($)’, namely ‘a {foo.bar.baz.quux}’ + In a stmt of a 'do' block: print $ a {foo.bar.baz.quux} In the expression: do let a = Foo {foo = ...} let quux = "Expecto patronum!" print $ a {foo.bar.baz.quux} - In an equation for ‘main’: - main - = do let a = ... - let quux = "Expecto patronum!" - print $ a {foo.bar.baz.quux} ===================================== testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr ===================================== @@ -4,11 +4,8 @@ RecordDotSyntaxFail13.hs:26:11: error: [GHC-39999] NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class. Insoluble functional dependencies wrt top-level instances • In the second argument of ‘($)’, namely ‘a {foo}’ + In a stmt of a 'do' block: print $ a {foo} In the expression: do let a = Foo {foo = 12} print $ a {foo} - In an equation for ‘main’: - main - = do let a = ... - print $ a {foo} ===================================== testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr ===================================== @@ -3,6 +3,7 @@ RecordDotSyntaxFail8.hs:47:17: error: [GHC-39999] arising from selecting the field ‘quux1’ NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class. • In the second argument of ‘($)’, namely ‘....bar.baz.quux1’ + In a stmt of a 'do' block: print @Quux $ ....baz.quux1 In the expression: do let a = Foo {foo = ...} print @Quux $ ....quux1 @@ -10,19 +11,13 @@ RecordDotSyntaxFail8.hs:47:17: error: [GHC-39999] print @Quux $ b.quux2 let c = Foo {foo = ...} ... - In an equation for ‘main’: - main - = do let a = ... - print @Quux $ ....quux1 - let b = myQuux - print @Quux $ b.quux2 - ... RecordDotSyntaxFail8.hs:50:17: error: [GHC-39999] • No instance for ‘HasField "quux2" Quux Quux’ arising from selecting the field ‘quux2’ NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class. • In the second argument of ‘($)’, namely ‘b.quux2’ + In a stmt of a 'do' block: print @Quux $ b.quux2 In the expression: do let a = Foo {foo = ...} print @Quux $ ....quux1 @@ -30,31 +25,12 @@ RecordDotSyntaxFail8.hs:50:17: error: [GHC-39999] print @Quux $ b.quux2 let c = Foo {foo = ...} ... - In an equation for ‘main’: - main - = do let a = ... - print @Quux $ ....quux1 - let b = myQuux - print @Quux $ b.quux2 - ... RecordDotSyntaxFail8.hs:53:17: error: [GHC-39999] • No instance for ‘HasField "quux3" Quux a0’ arising from selecting the field ‘quux3’ NB: ‘HasField’ is not the built-in ‘GHC.Internal.Records.HasField’ class. • In the expression: ....bar.baz.quux3 - In the expression: - do let a = Foo {foo = ...} - print @Quux $ ....quux1 - let b = myQuux - print @Quux $ b.quux2 - let c = Foo {foo = ...} - ... - In an equation for ‘main’: - main - = do let a = ... - print @Quux $ ....quux1 - let b = myQuux - print @Quux $ b.quux2 - ... + In the second argument of ‘($)’, namely ‘....baz.quux3.wob’ + In a stmt of a 'do' block: print @Bool $ ....quux3.wob View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb739088d2965feb4f75e5318d38f6a3... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb739088d2965feb4f75e5318d38f6a3... You're receiving this email because of your account on gitlab.haskell.org.