[Git][ghc/ghc] Pushed new branch wip/fendor/ghc-stack-profiler
by Hannes Siebenhandl (@fendor) 03 Nov '25
by Hannes Siebenhandl (@fendor) 03 Nov '25
03 Nov '25
Hannes Siebenhandl pushed new branch wip/fendor/ghc-stack-profiler at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fendor/ghc-stack-profiler
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/romes/hadrian-cross-stage2-rebase_SVEN_FIXED] Increase timeout for emulators
by Sven Tennie (@supersven) 03 Nov '25
by Sven Tennie (@supersven) 03 Nov '25
03 Nov '25
Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FIXED at Glasgow Haskell Compiler / GHC
Commits:
ca612978 by Sven Tennie at 2025-11-03T15:54:01+01:00
Increase timeout for emulators
Test runs with emulators naturally take longer than on native machines.
- - - - -
2 changed files:
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
Changes:
=====================================
.gitlab/generate-ci/gen_ci.hs
=====================================
@@ -20,6 +20,7 @@ import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.Set as S
import System.Environment
import Data.List
+import Data.Char (isSpace)
{-
Note [Generating the CI pipeline]
@@ -885,14 +886,24 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
Emulator s -> "CROSS_EMULATOR" =: s
NoEmulatorNeeded -> mempty
, if withNuma buildConfig then "ENABLE_NUMA" =: "1" else mempty
- , let runtestArgs =
+ , let testTimeoutArg =
+ case crossEmulator buildConfig of
+ -- Emulators are naturally slower than native machines.
+ -- Triple the default of 300.
+ Emulator _ -> "-e config.timeout=900" :: String
+ _ -> mempty
+ runtestArgs =
+ testTimeoutArg :
[ "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity"
| validateNonmovingGc buildConfig
]
- in "RUNTEST_ARGS" =: unwords runtestArgs
+ in "RUNTEST_ARGS" =: (trim . unwords) runtestArgs
, if testsuiteUsePerf buildConfig then "RUNTEST_ARGS" =: "--config perf_path=perf" else mempty
]
+ trim :: String -> String
+ trim = dropWhileEnd isSpace . dropWhile isSpace
+
jobArtifacts = Artifacts
{ junitReport = "junit.xml"
, expireIn = "2 weeks"
=====================================
.gitlab/jobs.yaml
=====================================
@@ -389,7 +389,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -471,7 +471,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -1060,7 +1060,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -1143,7 +1143,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -2055,7 +2055,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "aarch64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
"XZ_OPT": "-9"
}
@@ -2122,7 +2122,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "javascript-unknown-ghcjs",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"TEST_ENV": "x86_64-linux-deb11-emsdk-closure-int_native-cross_javascript-unknown-ghcjs-validate",
"XZ_OPT": "-9"
}
@@ -2504,7 +2504,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "riscv64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"TEST_ENV": "x86_64-linux-deb12-riscv-cross_riscv64-linux-gnu-validate",
"XZ_OPT": "-9"
}
@@ -3518,7 +3518,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "loongarch64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"TEST_ENV": "x86_64-linux-ubuntu24_04-loongarch-cross_loongarch64-linux-gnu-validate",
"XZ_OPT": "-9"
}
@@ -6165,7 +6165,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "aarch64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
}
},
@@ -6231,7 +6231,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "javascript-unknown-ghcjs",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"TEST_ENV": "x86_64-linux-deb11-emsdk-closure-int_native-cross_javascript-unknown-ghcjs-validate"
}
},
@@ -6608,7 +6608,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "riscv64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"TEST_ENV": "x86_64-linux-deb12-riscv-cross_riscv64-linux-gnu-validate"
}
},
@@ -7607,7 +7607,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "loongarch64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "-e config.timeout=900",
"TEST_ENV": "x86_64-linux-ubuntu24_04-loongarch-cross_loongarch64-linux-gnu-validate"
}
},
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca6129780c811d78cfbc04fde5f1ac5…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca6129780c811d78cfbc04fde5f1ac5…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/romes/hadrian-cross-stage2-rebase_SVEN_FIXED] Increase timeout for emulators
by Sven Tennie (@supersven) 03 Nov '25
by Sven Tennie (@supersven) 03 Nov '25
03 Nov '25
Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FIXED at Glasgow Haskell Compiler / GHC
Commits:
0de5dfde by Sven Tennie at 2025-11-03T09:52:18+01:00
Increase timeout for emulators
Test runs with emulators naturally take longer than on native machines.
- - - - -
2 changed files:
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
Changes:
=====================================
.gitlab/generate-ci/gen_ci.hs
=====================================
@@ -20,6 +20,7 @@ import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.Set as S
import System.Environment
import Data.List
+import Data.Char (isSpace)
{-
Note [Generating the CI pipeline]
@@ -885,14 +886,24 @@ job arch opsys buildConfig = NamedJob { name = jobName, jobInfo = Job {..} }
Emulator s -> "CROSS_EMULATOR" =: s
NoEmulatorNeeded -> mempty
, if withNuma buildConfig then "ENABLE_NUMA" =: "1" else mempty
- , let runtestArgs =
+ , let testTimeoutArg =
+ case crossEmulator buildConfig of
+ -- Emulators are naturally slower than native machines.
+ -- Triple the default of 300.
+ Emulator _ -> "--config=\"config.timeout=900\"" :: String
+ _ -> mempty
+ runtestArgs =
+ testTimeoutArg :
[ "--way=nonmoving --way=nonmoving_thr --way=nonmoving_thr_sanity"
| validateNonmovingGc buildConfig
]
- in "RUNTEST_ARGS" =: unwords runtestArgs
+ in "RUNTEST_ARGS" =: (trim . unwords) runtestArgs
, if testsuiteUsePerf buildConfig then "RUNTEST_ARGS" =: "--config perf_path=perf" else mempty
]
+ trim :: String -> String
+ trim = dropWhileEnd isSpace . dropWhile isSpace
+
jobArtifacts = Artifacts
{ junitReport = "junit.xml"
, expireIn = "2 weeks"
=====================================
.gitlab/jobs.yaml
=====================================
@@ -389,7 +389,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -471,7 +471,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -1060,7 +1060,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -1143,7 +1143,7 @@
"OBJCOPY": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objcopy",
"OBJDUMP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-objdump",
"RANLIB": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-llvm-ranlib",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"SIZE": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-size",
"STRINGS": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strings",
"STRIP": "/opt/llvm-mingw-linux/bin/aarch64-w64-mingw32-strip",
@@ -2055,7 +2055,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "aarch64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate",
"XZ_OPT": "-9"
}
@@ -2122,7 +2122,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "javascript-unknown-ghcjs",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"TEST_ENV": "x86_64-linux-deb11-emsdk-closure-int_native-cross_javascript-unknown-ghcjs-validate",
"XZ_OPT": "-9"
}
@@ -2504,7 +2504,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "riscv64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"TEST_ENV": "x86_64-linux-deb12-riscv-cross_riscv64-linux-gnu-validate",
"XZ_OPT": "-9"
}
@@ -3518,7 +3518,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "loongarch64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"TEST_ENV": "x86_64-linux-ubuntu24_04-loongarch-cross_loongarch64-linux-gnu-validate",
"XZ_OPT": "-9"
}
@@ -6165,7 +6165,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "aarch64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate"
}
},
@@ -6231,7 +6231,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "javascript-unknown-ghcjs",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"TEST_ENV": "x86_64-linux-deb11-emsdk-closure-int_native-cross_javascript-unknown-ghcjs-validate"
}
},
@@ -6608,7 +6608,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "riscv64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"TEST_ENV": "x86_64-linux-deb12-riscv-cross_riscv64-linux-gnu-validate"
}
},
@@ -7607,7 +7607,7 @@
"CROSS_STAGE": "2",
"CROSS_TARGET": "loongarch64-linux-gnu",
"INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
- "RUNTEST_ARGS": "",
+ "RUNTEST_ARGS": "--config=\"config.timeout=900\"",
"TEST_ENV": "x86_64-linux-ubuntu24_04-loongarch-cross_loongarch64-linux-gnu-validate"
}
},
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0de5dfde13e10a1166ae91f42a2d4a1…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0de5dfde13e10a1166ae91f42a2d4a1…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Simon Peyton Jones pushed to branch wip/T26514 at Glasgow Haskell Compiler / GHC
Commits:
4f516544 by Simon Peyton Jones at 2025-11-03T08:37:37+00:00
Wibble imports
- - - - -
1 changed file:
- compiler/GHC/Types/SourceText.hs
Changes:
=====================================
compiler/GHC/Types/SourceText.hs
=====================================
@@ -38,7 +38,6 @@ import GHC.Utils.Binary
import GHC.Utils.Panic
import Data.Function (on)
-import Data.Semigroup as S ((<>))
import Data.Data
import GHC.Real ( Ratio(..) )
import GHC.Types.SrcLoc
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f516544b4d3207d6c93566d4a7ecf1…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f516544b4d3207d6c93566d4a7ecf1…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T23162-spj] 19 commits: ghc-toolchain: detect PowerPC 64 bit ABI
by Simon Peyton Jones (@simonpj) 03 Nov '25
by Simon Peyton Jones (@simonpj) 03 Nov '25
03 Nov '25
Simon Peyton Jones pushed to branch wip/T23162-spj at Glasgow Haskell Compiler / GHC
Commits:
f75ab223 by Peter Trommler at 2025-10-31T18:43:13-04:00
ghc-toolchain: detect PowerPC 64 bit ABI
Check preprocessor macro defined for ABI v2 and assume v1 otherwise.
Fixes #26521
- - - - -
d086c474 by Peter Trommler at 2025-10-31T18:43:13-04:00
ghc-toolchain: refactor, move lastLine to Utils
- - - - -
995dfe0d by Vladislav Zavialov at 2025-10-31T18:43:54-04:00
Tests for -Wduplicate-exports, -Wdodgy-exports
Add test cases for the previously untested diagnostics:
[GHC-51876] TcRnDupeModuleExport
[GHC-64649] TcRnNullExportedModule
This also revealed a typo (incorrect capitalization of "module") in the
warning text for TcRnDupeModuleExport, which is now fixed.
- - - - -
f6961b02 by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: reformat dyld source code
This commit reformats dyld source code with prettier, to avoid
introducing unnecessary diffs in subsequent patches when they're
formatted before committing.
- - - - -
0c9032a0 by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: simplify _initialize logic in dyld
This commit simplifies how we _initialize a wasm shared library in
dyld and removes special treatment for libc.so, see added comment for
detailed explanation.
- - - - -
ec1b40bd by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: support running dyld fully client side in the browser
This commit refactors the wasm dyld script so that it can be used to
load and run wasm shared libraries fully client-side in the browser
without needing a wasm32-wasi-ghci backend:
- A new `DyLDBrowserHost` class is exported, which runs in the browser
and uses the in-memory vfs without any RPC calls. This meant to be
used to create a `rpc` object for the fully client side use cases.
- The exported `main` function now can be used to load user-specified
shared libraries, and the user can use the returned `DyLD` instance
to run their own exported Haskell functions.
- The in-browser wasi implementation is switched to
https://github.com/haskell-wasm/browser_wasi_shim for bugfixes and
major performance improvements not landed upstream yet.
- When being run by deno, it now correctly switches to non-nodejs code
paths, so it's more convenient to test dyld logic with deno.
See added comments for details, as well as the added `playground001`
test case for an example of using it to build an in-browser Haskell
playground.
- - - - -
8f3e481f by Cheng Shao at 2025-11-01T00:08:01+01:00
testsuite: add playground001 to test haskell playground
This commit adds the playground001 test case to test the haskell
playground in browser, see comments for details.
- - - - -
af40606a by Cheng Shao at 2025-11-01T00:08:04+01:00
Revert "testsuite: add T26431 test case"
This reverts commit 695036686f8c6d78611edf3ed627608d94def6b7. T26431
is now retired, wasm ghc internal-interpreter logic is tested by
playground001.
- - - - -
86c82745 by Vladislav Zavialov at 2025-11-01T07:24:29-04:00
Supplant TcRnExportHiddenComponents with TcRnDodgyExports (#26534)
Remove a bogus special case in lookup_ie_kids_all,
making TcRnExportHiddenComponents obsolete.
- - - - -
fcf6331e by Richard Eisenberg at 2025-11-03T08:33:05+00:00
Refactor fundep solving
This commit is a large-scale refactor of the increasingly-messy code that
handles functional dependencies. It has virtually no effect on what compiles
but improves error messages a bit. And it does the groundwork for #23162.
The big picture is described in
Note [Overview of functional dependencies in type inference]
in GHC.Tc.Solver.FunDeps
* New module GHC.Tc.Solver.FunDeps contains all the fundep-handling
code for the constraint solver.
* Fundep-equalities are solved in a nested scope; they may generate
unifications but otherwise have no other effect.
See GHC.Tc.Solver.FunDeps.solveFunDeps
The nested needs to start from the Givens in the inert set, but
not the Wanteds; hence a new function `resetInertCans`, used in
`nestFunDepsTcS`.
* That in turn means that fundep equalities never show up in error
messages, so the complicated FunDepOrigin tracking can all disappear.
* We need to be careful about tracking unifications, so we kick out
constraints from the inert set after doing unifications. Unification
tracking has been majorly reformed: see Note [WhatUnifications] in
GHC.Tc.Utils.Unify.
A good consequence is that the hard-to-grok `resetUnificationFlag`
has been replaced with a simpler use of
`reportCoarseGrainUnifications`
Smaller things:
* Rename `FunDepEqn` to `FunDepEqns` since it contains multiple
type equalities.
Some compile time improvement
Metrics: compile_time/bytes allocated
Baseline
Test value New value Change
---------------------- --------------------------------------
T5030(normal) 173,839,232 148,115,248 -14.8% GOOD
hard_hole_fits(normal) 286,768,048 284,015,416 -1.0%
geo. mean -0.2%
minimum -14.8%
maximum +0.3%
Metric Decrease:
T5030
- - - - -
231adc30 by Simon Peyton Jones at 2025-11-03T08:33:05+00:00
QuickLook's tcInstFun should make instantiation variables directly
tcInstFun must make "instantiation variables", not regular
unification variables, when instantiating function types. That was
previously implemented by a hack: set the /ambient/ level to QLInstTyVar.
But the hack finally bit me, when I was refactoring WhatUnifications.
And it was always wrong: see the now-expunged (TCAPP2) note.
This commit does it right, by making tcInstFun call its own
instantiation functions. That entails a small bit of duplication,
but the result is much, much cleaner.
- - - - -
39d4a24b by Simon Peyton Jones at 2025-11-03T08:33:05+00:00
Build implication for constraints from (static e)
This commit addresses #26466, by buiding an implication for the
constraints arising from a (static e) form. The implication has
a special ic_info field of StaticFormSkol, which tells the constraint
solver to use an empty set of Givens.
See (SF3) in Note [Grand plan for static forms]
in GHC.Iface.Tidy.StaticPtrTable
This commit also reinstates an `assert` in GHC.Tc.Solver.Equality.
The test `StaticPtrTypeFamily` was failing with an assertion failure,
but it now works.
- - - - -
2e2aec1e by Simon Peyton Jones at 2025-11-03T08:33:05+00:00
Comments about defaulting representation equalities
- - - - -
52a4d1da by Simon Peyton Jones at 2025-11-03T08:33:05+00:00
Improve tracking of rewriter-sets
This refactor substantially improves the treatment of so-called
"rewriter-sets" in the constraint solver.
The story is described in the rewritten
Note [Wanteds rewrite Wanteds: rewriter-sets]
in GHC.Tc.Types.Constraint
Some highlights
* Trace the free coercion holes of a filled CoercionHole,
in CoercionPlusHoles. See Note [Coercion holes] (COH5)
This avoids taking having to take the free coercion variables
of a coercion when zonking a rewrriter-set
* Many knock on changes
* Make fillCoercionHole take CoercionPlusHoles as its argument
rather than to separate arguments.
* Similarly setEqIfWanted, setWantedE, wrapUnifierAndEmit.
* Be more careful about passing the correct CoHoleSet to
`rewriteEqEvidence` and friends
* Make kickOurAfterFillingCoercionHole more clever. See
new Note [Kick out after filling a coercion hole]
Smaller matters
* Rename RewriterSet to CoHoleSet
* Add special-case helper `rewriteEqEvidenceSwapOnly`
- - - - -
3e78e1ba by Simon Peyton Jones at 2025-11-03T08:33:05+00:00
Tidy up constraint solving for foralls
* In `can_eq_nc_forall` make sure to track Givens that are used
in the nested solve step.
* Tiny missing-swap bug-fix in `lookup_eq_in_qcis`
* Fix some leftover mess from
commit 14123ee646f2b9738a917b7cec30f9d3941c13de
Author: Simon Peyton Jones <simon.peytonjones(a)gmail.com>
Date: Wed Aug 20 00:35:48 2025 +0100
Solve forall-constraints via an implication, again
Specifically, trySolveImplication is now dead.
- - - - -
973f2c25 by Simon Peyton Jones at 2025-11-03T08:33:05+00:00
Do not treat CoercionHoles as free variables in coercions
This fixes a long-standing wart in the free-variable finder;
now CoercionHoles are no longer treated as a "free variable"
of a coercion.
I got big and unexpected performance regressions when making
this change. Turned out that CallArity didn't discover that
the free variable finder could be eta-expanded, which gave very
poor code.
So I re-used Note [The one-shot state monad trick] for Endo,
resulting in GHC.Utils.EndoOS. Very simple, big win.
- - - - -
c2b8a0f9 by Simon Peyton Jones at 2025-11-03T08:33:05+00:00
Update debug-tracing in CallArity
No effect on behaviour, and commented out anyway
- - - - -
9aa5ee99 by Simon Peyton Jones at 2025-11-03T08:33:28+00:00
Comments only -- remove dangling Note references
- - - - -
6683f183 by Simon Peyton Jones at 2025-11-03T08:33:28+00:00
Accept error message wibbles
- - - - -
121 changed files:
- compiler/GHC/Core/Opt/CallArity.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Iface/Tidy/StaticPtrTable.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Sig.hs
- compiler/GHC/Tc/Instance/FunDeps.hs
- compiler/GHC/Tc/Solver.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Equality.hs
- + compiler/GHC/Tc/Solver/FunDeps.hs
- compiler/GHC/Tc/Solver/InertSet.hs
- compiler/GHC/Tc/Solver/Irred.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Rewrite.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/Solver/Solve.hs-boot
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Concrete.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Unique/DSM.hs
- + compiler/GHC/Utils/EndoOS.hs
- compiler/ghc.cabal.in
- testsuite/tests/count-deps/CountDepsAst.stdout
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/default/default-fail05.stderr
- testsuite/tests/dependent/should_fail/T13135_simple.stderr
- testsuite/tests/deriving/should_fail/T3621.stderr
- testsuite/tests/diagnostic-codes/codes.stdout
- + testsuite/tests/ghc-api-browser/README.md
- + testsuite/tests/ghc-api-browser/all.T
- + testsuite/tests/ghc-api-browser/index.html
- + testsuite/tests/ghc-api-browser/playground001.hs
- + testsuite/tests/ghc-api-browser/playground001.js
- + testsuite/tests/ghc-api-browser/playground001.sh
- testsuite/tests/ghci-wasm/T26431.stdout → testsuite/tests/ghc-api-browser/playground001.stdout
- − testsuite/tests/ghci-wasm/T26431.hs
- testsuite/tests/ghci-wasm/all.T
- testsuite/tests/indexed-types/should_fail/T14369.stderr
- testsuite/tests/indexed-types/should_fail/T1897b.stderr
- testsuite/tests/linters/notes.stdout
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr
- testsuite/tests/parser/should_fail/T20654a.stderr
- testsuite/tests/partial-sigs/should_fail/T14584a.stderr
- testsuite/tests/polykinds/T6068.stdout
- testsuite/tests/quantified-constraints/T15359.hs
- testsuite/tests/rep-poly/RepPolyNPlusK.stderr
- testsuite/tests/rep-poly/RepPolyRightSection.stderr
- testsuite/tests/rep-poly/T13233.stderr
- testsuite/tests/rep-poly/T19709b.stderr
- testsuite/tests/rep-poly/T23903.stderr
- testsuite/tests/typecheck/no_skolem_info/T13499.stderr
- testsuite/tests/typecheck/should_compile/T13651.hs
- − testsuite/tests/typecheck/should_compile/T13651.stderr
- + testsuite/tests/typecheck/should_compile/T14745.hs
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_compile/hole_constraints_nested.stderr
- testsuite/tests/typecheck/should_compile/tc126.hs
- testsuite/tests/typecheck/should_fail/AmbigFDs.hs
- − testsuite/tests/typecheck/should_fail/AmbigFDs.stderr
- testsuite/tests/typecheck/should_fail/FD3.stderr
- testsuite/tests/typecheck/should_fail/FDsFromGivens2.stderr
- testsuite/tests/typecheck/should_fail/T13506.stderr
- testsuite/tests/typecheck/should_fail/T16512a.stderr
- testsuite/tests/typecheck/should_fail/T18851b.hs
- − testsuite/tests/typecheck/should_fail/T18851b.stderr
- testsuite/tests/typecheck/should_fail/T18851c.hs
- − testsuite/tests/typecheck/should_fail/T18851c.stderr
- testsuite/tests/typecheck/should_fail/T19415.stderr
- testsuite/tests/typecheck/should_fail/T19415b.stderr
- testsuite/tests/typecheck/should_fail/T22684.stderr
- + testsuite/tests/typecheck/should_fail/T23162a.hs
- + testsuite/tests/typecheck/should_fail/T23162a.stderr
- testsuite/tests/typecheck/should_fail/T25325.stderr
- testsuite/tests/typecheck/should_fail/T5246.stderr
- testsuite/tests/typecheck/should_fail/T5978.stderr
- testsuite/tests/typecheck/should_fail/T7368a.stderr
- testsuite/tests/typecheck/should_fail/T7696.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/TcStaticPointersFail03.stderr
- testsuite/tests/typecheck/should_fail/all.T
- testsuite/tests/typecheck/should_fail/tcfail122.stderr
- testsuite/tests/typecheck/should_fail/tcfail143.stderr
- + testsuite/tests/warnings/should_compile/DodgyExports02.hs
- + testsuite/tests/warnings/should_compile/DodgyExports02.stderr
- + testsuite/tests/warnings/should_compile/DodgyExports03.hs
- + testsuite/tests/warnings/should_compile/DodgyExports03.stderr
- + testsuite/tests/warnings/should_compile/DuplicateModExport.hs
- + testsuite/tests/warnings/should_compile/DuplicateModExport.stderr
- + testsuite/tests/warnings/should_compile/EmptyModExport.hs
- + testsuite/tests/warnings/should_compile/EmptyModExport.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/ghc-toolchain/ghc-toolchain.cabal
- utils/ghc-toolchain/src/GHC/Toolchain/CheckArm.hs
- + utils/ghc-toolchain/src/GHC/Toolchain/CheckPower.hs
- utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs
- utils/jsffi/dyld.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/09161c1fd6bad28b2c43fefee4100d…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/09161c1fd6bad28b2c43fefee4100d…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-apporv-Oct24] 3 commits: accept new test output
by Apoorv Ingle (@ani) 02 Nov '25
by Apoorv Ingle (@ani) 02 Nov '25
02 Nov '25
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
81d9fe03 by Apoorv Ingle at 2025-11-02T21:39:48-06:00
accept new test output
- - - - -
e75752ed by Apoorv Ingle at 2025-11-02T22:44:08-06:00
Do not use HsPar in Last statement
- - - - -
f556b226 by Apoorv Ingle at 2025-11-02T22:44:31-06:00
accept test cases
- - - - -
21 changed files:
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Head.hs
- testsuite/tests/default/default-fail05.stderr
- testsuite/tests/indexed-types/should_fail/T2693.stderr
- testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
- testsuite/tests/plugins/test-defaulting-plugin.stderr
- testsuite/tests/polykinds/T13393.stderr
- testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
- testsuite/tests/typecheck/should_fail/T10971d.stderr
- testsuite/tests/typecheck/should_fail/T13311.stderr
- testsuite/tests/typecheck/should_fail/T24064.stderr
- testsuite/tests/typecheck/should_fail/T3613.stderr
- testsuite/tests/typecheck/should_fail/T6069.stderr
- testsuite/tests/typecheck/should_fail/T7851.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/tcfail128.stderr
- testsuite/tests/typecheck/should_fail/tcfail140.stderr
- testsuite/tests/typecheck/should_fail/tcfail168.stderr
- testsuite/tests/typecheck/should_fail/tcfail181.stderr
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
Changes:
=====================================
compiler/GHC/Tc/Gen/Do.hs
=====================================
@@ -81,15 +81,15 @@ expand_do_stmts flav [stmt@(L sloc (LastStmt _ body@(L body_loc _) _ ret_expr))]
-- See `checkLastStmt` and `Syntax.Expr.StmtLR.LastStmt`
| NoSyntaxExprRn <- ret_expr
-- Last statement is just body if we are not in ListComp context. See Syntax.Expr.LastStmt
- = return $ L sloc (mkExpandedStmt stmt flav (HsPar noExtField body))
+ = return $ L sloc (mkExpandedStmt stmt flav (unLoc body))
| SyntaxExprRn ret <- ret_expr -- We have unfortunately lost the location on the return function :(
--
-- ------------------------------------------------
-- return e ~~> return e
-- to make T18324 work
- = do let expansion = L body_loc (genHsApp ret body)
- return $ L sloc (mkExpandedStmt stmt flav (HsPar noExtField expansion))
+ = do let expansion = HsApp noExtField (L body_loc ret) body
+ return $ L sloc (mkExpandedStmt stmt flav expansion)
expand_do_stmts doFlavour (stmt@(L loc (LetStmt _ bs)) : lstmts) =
-- See Note [Expanding HsDo with XXExprGhcRn] Equation (3) below
=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -1119,6 +1119,9 @@ addExprCtxt e thing_inside
addLExprCtxt :: LHsExpr GhcRn -> TcRn a -> TcRn a
addLExprCtxt (L lspan e) thing_inside
+ | (RealSrcSpan{}) <- locA lspan
+ , (HsPar _ e') <- e
+ = addExprCtxt (unLoc e') thing_inside
| (RealSrcSpan{}) <- locA lspan
= addExprCtxt e thing_inside
| otherwise
=====================================
testsuite/tests/default/default-fail05.stderr
=====================================
@@ -11,7 +11,7 @@ default-fail05.hs:11:10: error: [GHC-39999]
(use -fprint-potential-instances to see them all)
• In the first argument of ‘($)’, namely ‘toList’
In the first argument of ‘print’, namely ‘(toList $ pure 21)’
- In the expression: print (toList $ pure 21)
+ In a stmt of a 'do' block: print (toList $ pure 21)
default-fail05.hs:11:19: error: [GHC-39999]
• Ambiguous type variable ‘t0’ arising from a use of ‘pure’
@@ -25,10 +25,10 @@ default-fail05.hs:11:19: error: [GHC-39999]
(use -fprint-potential-instances to see them all)
• In the second argument of ‘($)’, namely ‘pure 21’
In the first argument of ‘print’, namely ‘(toList $ pure 21)’
- In the expression: print (toList $ pure 21)
+ In a stmt of a 'do' block: print (toList $ pure 21)
default-fail05.hs:12:3: error: [GHC-39999]
- • Ambiguous type variable ‘t1’ arising from a use of ‘traverse’
+ • Ambiguous type variable ‘t1’ arising from a do statement
prevents the constraint ‘(Traversable t1)’ from being solved.
Relevant bindings include
main :: IO (t1 ()) (bound at default-fail05.hs:10:1)
=====================================
testsuite/tests/indexed-types/should_fail/T2693.stderr
=====================================
@@ -42,8 +42,5 @@ T2693.hs:29:20: error: [GHC-83865]
The type variable ‘a0’ is ambiguous
• In the first argument of ‘mapM’, namely ‘g’
In the expression: mapM g undefined
- In the expression:
- do pvs <- mapM g undefined
- let n = (map ...) `min` (map ...)
- undefined
+ In a stmt of a 'do' block: pvs <- mapM g undefined
=====================================
testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
=====================================
@@ -42,7 +42,7 @@ T26480b.hs:43:12: error: [GHC-39999]
T26480b.hs:47:10: error: [GHC-39999]
• No instance for ‘HasField "xyzzywyzzydyzzd" G H’
- arising from the record selector ‘xyzzywyzzydyzzd’
+ arising from the expression (.xyzzywyzzydyzzd)
NB: ‘G’ does not have a record field named ‘xyzzywyzzydyzzd’.
• In the expression: (.xyzzywyzzydyzzd)
In an equation for ‘test3a’: test3a = (.xyzzywyzzydyzzd)
@@ -50,6 +50,7 @@ T26480b.hs:47:10: error: [GHC-39999]
T26480b.hs:50:10: error: [GHC-39999]
• No instance for ‘HasField "xyzzywyzzydyzze" G H’
+ arising from the expression (.field1.xyzzywyzzydyzze)
NB: ‘G’ does not have a record field named ‘xyzzywyzzydyzze’.
• In the expression: (.field1.xyzzywyzzydyzze)
In an equation for ‘test3b’: test3b = (.field1.xyzzywyzzydyzze)
@@ -66,6 +67,7 @@ T26480b.hs:54:12: error: [GHC-39999]
T26480b.hs:57:12: error: [GHC-39999]
• No instance for ‘HasField "xyzzywyzzydyzzg" G H’
+ arising from a record update
NB: ‘G’ does not have a record field named ‘xyzzywyzzydyzzg’.
• In the expression: d {field1.xyzzywyzzydyzzg = MkH 3}
In an equation for ‘test4b’:
=====================================
testsuite/tests/plugins/test-defaulting-plugin.stderr
=====================================
@@ -3,7 +3,7 @@ test-defaulting-plugin.hs:28:11: warning: [GHC-18042] [-Wtype-defaults (in -Wall
KnownNat a0 arising from a use of ‘q’
• In the first argument of ‘(+)’, namely ‘q’
In the second argument of ‘($)’, namely ‘q + w’
- In the expression: print $ q + w
+ In a stmt of a 'do' block: print $ q + w
test-defaulting-plugin.hs:28:15: warning: [GHC-18042] [-Wtype-defaults (in -Wall)]
• Defaulting the type variable ‘a0’ to type ‘2’ in the following constraints
@@ -15,7 +15,7 @@ test-defaulting-plugin.hs:28:15: warning: [GHC-18042] [-Wtype-defaults (in -Wall
arising from a use of ‘w’ at test-defaulting-plugin.hs:28:15
• In the second argument of ‘(+)’, namely ‘w’
In the second argument of ‘($)’, namely ‘q + w’
- In the expression: print $ q + w
+ In a stmt of a 'do' block: print $ q + w
test-defaulting-plugin.hs:29:11: warning: [GHC-18042] [-Wtype-defaults (in -Wall)]
• Defaulting the type variable ‘b0’ to type ‘0’ in the following constraint
=====================================
testsuite/tests/polykinds/T13393.stderr
=====================================
@@ -1,25 +1,26 @@
T13393.hs:61:3: error: [GHC-39999]
- • Ambiguous type variable ‘t0’ arising from a use of ‘mapM’
+ • Ambiguous type variable ‘t0’ arising from a do statement
prevents the constraint ‘(Traversable t0)’ from being solved.
Probable fix: use a type annotation to specify what ‘t0’ should be.
Potentially matching instances:
- instance Traversable (Either a)
- -- Defined in ‘GHC.Internal.Data.Traversable’
- instance Traversable Identity
- -- Defined in ‘GHC.Internal.Data.Traversable’
- ...plus four others
- ...plus 27 instances involving out-of-scope types
- (use -fprint-potential-instances to see them all)
- • In the expression:
- mapM putBackLeftOverInputAndReturnOutput undefined
+ instance Traversable (Either a)
+ -- Defined in ‘GHC.Internal.Data.Traversable’
+ instance Traversable Identity
+ -- Defined in ‘GHC.Internal.Data.Traversable’
+ ...plus four others
+ ...plus 27 instances involving out-of-scope types
+ (use -fprint-potential-instances to see them all)
+ • In a stmt of a 'do' block:
+ mapM putBackLeftOverInputAndReturnOutput undefined
In the expression:
- do mapM putBackLeftOverInputAndReturnOutput undefined
- undefined
+ do mapM putBackLeftOverInputAndReturnOutput undefined
+ undefined
In an equation for ‘encodeLinearToAac’:
- encodeLinearToAac
- = do mapM putBackLeftOverInputAndReturnOutput undefined
- undefined
- where
- putBackLeftOverInputAndReturnOutput (MkEncodeResult x)
- = do leftOvers .= x
- undefined
+ encodeLinearToAac
+ = do mapM putBackLeftOverInputAndReturnOutput undefined
+ undefined
+ where
+ putBackLeftOverInputAndReturnOutput (MkEncodeResult x)
+ = do leftOvers .= x
+ undefined
+
=====================================
testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
=====================================
@@ -12,15 +12,11 @@ valid_hole_fits.hs:9:6: warning: [GHC-88464] [-Wdeferred-out-of-scope-variables
valid_hole_fits.hs:17:17: warning: [GHC-88464] [-Wtyped-holes (in -Wdefault)]
• Found hole: _ :: Int -> IO Int
• In the expression: _ x
+ In a stmt of a 'do' block: y <- _ x
In the expression:
do x <- a 0
y <- _ x
return y
- In an equation for ‘c’:
- c _
- = do x <- a 0
- y <- _ x
- return y
• Relevant bindings include
x :: Int (bound at valid_hole_fits.hs:16:12)
c :: Int -> IO Int (bound at valid_hole_fits.hs:16:1)
=====================================
testsuite/tests/typecheck/should_fail/T10971d.stderr
=====================================
@@ -3,14 +3,14 @@ T10971d.hs:4:14: error: [GHC-83865]
with actual type: Maybe a3
• In the first argument of ‘f’, namely ‘(Just 1)’
In the second argument of ‘($)’, namely ‘f (Just 1)’
- In the expression: print $ f (Just 1)
+ In a stmt of a 'do' block: print $ f (Just 1)
T10971d.hs:5:19: error: [GHC-83865]
• Couldn't match expected type: [b0]
with actual type: Maybe a4
• In the second argument of ‘g’, namely ‘(Just 5)’
In the second argument of ‘($)’, namely ‘g (+ 1) (Just 5)’
- In the expression: print $ g (+ 1) (Just 5)
+ In a stmt of a 'do' block: print $ g (+ 1) (Just 5)
T10971d.hs:6:23: error: [GHC-83865]
• Couldn't match expected type: [a2]
=====================================
testsuite/tests/typecheck/should_fail/T13311.stderr
=====================================
@@ -2,7 +2,7 @@ T13311.hs:9:3: error: [GHC-83865]
• Couldn't match expected type: IO a0
with actual type: Maybe a1 -> Maybe b0
• Probable cause: ‘f’ is applied to too few arguments
- In the expression: f
+ In a stmt of a 'do' block: f
In the expression:
do f
putChar 'a'
=====================================
testsuite/tests/typecheck/should_fail/T24064.stderr
=====================================
@@ -10,7 +10,7 @@ T24064.hs:42:3: error: [GHC-25897]
the type signature for:
test :: forall (m :: * -> *). (C2 m, F2 m ~ Y) => m ()
at T24064.hs:40:1-32
- • In the expression: fun1
+ • In a stmt of a 'do' block: fun1
In the expression:
do fun1
fun2
=====================================
testsuite/tests/typecheck/should_fail/T3613.stderr
=====================================
@@ -10,7 +10,7 @@ T3613.hs:17:24: error: [GHC-83865]
• Couldn't match type ‘IO’ with ‘Maybe’
Expected: Maybe ()
Actual: IO ()
- • In the expression: bar
+ • In a stmt of a 'do' block: bar
In the first argument of ‘fooThen’, namely
‘(do bar
undefined)’
=====================================
testsuite/tests/typecheck/should_fail/T6069.stderr
=====================================
@@ -1,4 +1,3 @@
-
T6069.hs:13:15: error: [GHC-83865]
• Couldn't match type: forall s. ST s b0
with: ST s0 Int
@@ -24,4 +23,5 @@ T6069.hs:15:16: error: [GHC-83865]
Actual: (forall s. ST s b2) -> b2
• In the second argument of ‘(.)’, namely ‘runST’
In the expression: print . runST
- In the expression: ((print . runST) $) fourty_two
+ In the expression: (print . runST) $
+
=====================================
testsuite/tests/typecheck/should_fail/T7851.stderr
=====================================
@@ -2,7 +2,7 @@ T7851.hs:5:10: error: [GHC-83865]
• Couldn't match expected type: IO a0
with actual type: a1 -> IO ()
• Probable cause: ‘print’ is applied to too few arguments
- In the expression: print
+ In a stmt of a 'do' block: print
In the expression:
do print
print "Hello"
=====================================
testsuite/tests/typecheck/should_fail/T8603.stderr
=====================================
@@ -10,7 +10,5 @@ T8603.hs:33:17: error: [GHC-18872]
m a -> t m a’
has only one
In the expression: lift uniform [1, 2, 3]
- In the expression:
- do prize <- lift uniform [1, 2, 3]
- return False
+ In a stmt of a 'do' block: prize <- lift uniform [1, 2, 3]
=====================================
testsuite/tests/typecheck/should_fail/T9612.stderr
=====================================
@@ -3,9 +3,9 @@ T9612.hs:16:9: error: [GHC-18872]
with: (Int, a)
arising from a functional dependency between:
constraint ‘MonadWriter (Int, a) (WriterT [(Int, a)] Identity)’
- arising from a use of ‘tell’
+ arising from a do statement
instance ‘MonadWriter w (WriterT w m)’ at T9612.hs:20:10-59
- • In the expression: tell (n, x)
+ • In a stmt of a 'do' block: tell (n, x)
In the expression:
do tell (n, x)
return (1, y)
=====================================
testsuite/tests/typecheck/should_fail/tcfail128.stderr
=====================================
@@ -6,6 +6,7 @@ tcfail128.hs:18:16: error: [GHC-39999]
one instance involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the expression: thaw tmp
+ In a stmt of a 'do' block: v <- thaw tmp
In the expression:
do let sL = [...]
dim = length sL
@@ -13,11 +14,4 @@ tcfail128.hs:18:16: error: [GHC-39999]
...
v <- thaw tmp
return ()
- In an equation for ‘main’:
- main
- = do let sL = ...
- dim = length sL
- ...
- v <- thaw tmp
- return ()
=====================================
testsuite/tests/typecheck/should_fail/tcfail140.stderr
=====================================
@@ -17,7 +17,8 @@ tcfail140.hs:13:10: error: [GHC-83865]
tcfail140.hs:15:15: error: [GHC-83865]
• Couldn't match expected type ‘t -> b’ with actual type ‘Int’
- • In the first argument of ‘map’, namely ‘(3 `f`)’
+ • Possible cause: ‘f’ is applied to too many arguments
+ In the first argument of ‘map’, namely ‘(3 `f`)’
In the expression: map (3 `f`) xs
In an equation for ‘bot’: bot xs = map (3 `f`) xs
• Relevant bindings include
=====================================
testsuite/tests/typecheck/should_fail/tcfail168.stderr
=====================================
@@ -1,19 +1,20 @@
tcfail168.hs:7:11: error: [GHC-83865]
• Couldn't match expected type: IO a0
- with actual type: Char -> IO ()
+ with actual type: Char -> IO ()
• Probable cause: ‘putChar’ is applied to too few arguments
- In the expression: putChar
+ In a stmt of a 'do' block: putChar
In the expression:
- do putChar
- putChar 'a'
- putChar 'a'
- putChar 'a'
- putChar 'a'
- ...
+ do putChar
+ putChar 'a'
+ putChar 'a'
+ putChar 'a'
+ putChar 'a'
+ ...
In an equation for ‘foo’:
- foo
- = do putChar
- putChar 'a'
- putChar 'a'
- putChar 'a'
- ...
+ foo
+ = do putChar
+ putChar 'a'
+ putChar 'a'
+ putChar 'a'
+ ...
+
=====================================
testsuite/tests/typecheck/should_fail/tcfail181.stderr
=====================================
@@ -1,6 +1,5 @@
-
tcfail181.hs:17:9: error: [GHC-39999]
- • Could not deduce ‘Monad m0’ arising from a use of ‘foo’
+ • Could not deduce ‘Monad m0’ arising from a record update
from the context: Monad m
bound by the inferred type of
wog :: Monad m => p -> Something (m Bool) e
@@ -12,8 +11,9 @@ tcfail181.hs:17:9: error: [GHC-39999]
...plus six others
...plus one instance involving out-of-scope types
(use -fprint-potential-instances to see them all)
- • In the expression: foo
- In a record update at field ‘bar’,
+ • In a record update at field ‘bar’,
with type constructor ‘Something’
and data constructor ‘Something’.
In the expression: foo {bar = return True}
+ In an equation for ‘wog’: wog x = foo {bar = return True}
+
=====================================
testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
=====================================
@@ -1,7 +1,7 @@
CaretDiagnostics1.hs:7:8-15: error: [GHC-83865]
• Couldn't match expected type ‘IO a0’ with actual type ‘Int’
• In the second argument of ‘(+)’, namely ‘(3 :: Int)’
- In the expression:
+ In a stmt of a 'do' block:
10000000000000000000000000000000000000 + 2 + (3 :: Int)
In the expression:
do 10000000000000000000000000000000000000 + 2 + (3 :: Int)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc871fb970034810dc8854affdd642…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dc871fb970034810dc8854affdd642…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T24464] 28 commits: Improve error handling in 'getPackageArchives'
by Simon Peyton Jones (@simonpj) 02 Nov '25
by Simon Peyton Jones (@simonpj) 02 Nov '25
02 Nov '25
Simon Peyton Jones pushed to branch wip/T24464 at Glasgow Haskell Compiler / GHC
Commits:
91b6be10 by Julian Ospald at 2025-10-20T18:21:03-04:00
Improve error handling in 'getPackageArchives'
When the library dirs in the package conf files are not set up correctly,
the JS linker will happily ignore such packages and not link against them,
although they're part of the link plan.
Fixes #26383
- - - - -
6c5269da by Sven Tennie at 2025-10-20T18:21:44-04:00
Align coding style
Improve readability by using the same style for all constructor calls in
this function.
- - - - -
3d305889 by Sven Tennie at 2025-10-20T18:21:44-04:00
Reduce complexity by removing joins with mempty
ldArgs, cArgs and cppArgs are all `mempty`. Thus concatenating them adds
nothing but some complexity while reading the code.
- - - - -
38d65187 by Matthew Pickering at 2025-10-21T13:12:20+01:00
Fix stack decoding when using profiled runtime
There are three fixes in this commit.
* We need to replicate the `InfoTable` and `InfoTableProf`
approach for the other stack constants (see the new Stack.ConstantsProf
file).
* Then we need to appropiately import the profiled or non-profiled
versions.
* Finally, there was an incorrect addition in `stackFrameSize`. We need
to cast after performing addition on words.
Fixes #26507
- - - - -
17231bfb by fendor at 2025-10-21T13:12:20+01:00
Add regression test for #26507
- - - - -
4f5bf93b by Simon Peyton Jones at 2025-10-25T04:05:34-04:00
Postscript to fix for #26255
This MR has comments only
- - - - -
6ef22fa0 by IC Rainbow at 2025-10-26T18:23:01-04:00
Add SIMD primops for bitwise logical operations
This adds 128-bit wide and/or/xor instructions for X86 NCG,
with both SSE and AVX encodings.
```
andFloatX4# :: FloatX4# -> FloatX4# -> FloatX4# -- andps / vandps
andDoubleX2# :: DoubleX2# -> DoubleX2# -> DoubleX2# -- andpd / vandpd
andInt8X16# :: Int8X16# -> Int8X16# -> Int8X16# -- pand / vpand
```
The new primops are available on ARM when using LLVM backend.
Tests added:
- simd015 (floats and doubles)
- simd016 (integers)
- simd017 (words)
Fixes #26417
- - - - -
fbdc623a by sheaf at 2025-10-26T18:23:52-04:00
Add hints for unsolved HasField constraints
This commit adds hints and explanations for unsolved 'HasField'
constraints.
GHC will now provide additional explanations for an unsolved constraint
of the form 'HasField fld_name rec_ty fld_ty'; the details are laid out in
Note [Error messages for unsolved HasField constraints], but briefly:
1. Provide similar name suggestions (e.g. mis-spelled field name)
and import suggestions (record field not in scope).
These result in actionable 'GhcHints', which is helpful to provide
code actions in HLS.
2. Explain why GHC did not solve the constraint, e.g.:
- 'fld_name' is not a string literal (e.g. a type variable)
- 'rec_ty' is a TyCon without any fields, e.g. 'Int' or 'Bool'.
- 'fld_ty' contains existentials variables or foralls.
- The record field is a pattern synonym field (GHC does not generate
HasField instances for those).
- 'HasField' is a custom 'TyCon', not actually the built-in
'HasField' typeclass from 'GHC.Records'.
On the way, we slightly refactor the mechanisms for import suggestions
in GHC.Rename.Unbound. This is to account for the fact that, for
'HasField', we don't care whether the field is imported qualified or
unqualified. 'importSuggestions' was refactored, we now have
'sameQualImportSuggestions' and 'anyQualImportSuggestions'.
Fixes #18776 #22382 #26480
- - - - -
99d5707f by sheaf at 2025-10-26T18:23:52-04:00
Rename PatSyn MatchContext to PatSynCtx to avoid punning
- - - - -
5dc2e9ea by Julian Ospald at 2025-10-27T18:17:23-04:00
Skip uniques test if sources are not available
- - - - -
544b9ec9 by Vladislav Zavialov at 2025-10-27T18:18:06-04:00
Re-export GHC.Hs.Basic from GHC.Hs
Clean up some import sections in GHC by re-exporting GHC.Hs.Basic
from GHC.Hs.
- - - - -
643ce801 by Julian Ospald at 2025-10-28T18:18:55-04:00
rts: remove unneccesary cabal flags
We perform those checks via proper autoconf macros
instead that do the right thing and then add those
libs to the rts buildinfo.
- - - - -
d69ea8fe by Vladislav Zavialov at 2025-10-28T18:19:37-04:00
Test case for #17705
Starting with GHC 9.12 (the first release to include 5745dbd3),
all examples in this ticket are handled as expected.
- - - - -
4038a28b by Andreas Klebinger at 2025-10-30T12:38:52-04:00
Add a perf test for #26425
- - - - -
f997618e by Andreas Klebinger at 2025-10-30T12:38:52-04:00
OccAnal: Be stricter for better compiler perf.
In particular we are now stricter:
* When combining usageDetails.
* When computing binder info.
In combineUsageDetails when combining the underlying adds we compute a
new `LocalOcc` for each entry by combining the two existing ones.
Rather than wait for those entries to be forced down the road we now
force them immediately. Speeding up T26425 by about 10% with little
effect on the common case.
We also force binders we put into the Core AST everywhere now.
Failure to do so risks leaking the occ env used to set the binders
OccInfo.
For T26425 compiler residency went down by a factor of ~10x.
Compile time also improved by a factor of ~1.6.
-------------------------
Metric Decrease:
T18698a
T26425
T9233
-------------------------
- - - - -
5618645b by Vladislav Zavialov at 2025-10-30T12:39:33-04:00
Fix namespace specifiers in subordinate exports (#12488)
This patch fixes an oversight in the `lookupChildrenExport` function that
caused explicit namespace specifiers of subordinate export items to be
ignored:
module M (T (type A)) where -- should be rejected
data T = A
Based on the `IEWrappedName` data type, there are 5 cases to consider:
1. Unadorned name: P(X)
2. Named default: P(default X)
3. Pattern synonym: P(pattern X)
4. Type name: P(type X)
5. Data name: P(data X)
Case 1 is already handled correctly; cases 2 and 3 are parse errors; and
it is cases 4 and 5 that we are concerned with in this patch.
Following the precedent established in `LookupExactName`, we introduce
a boolean flag in `LookupChildren` to control whether to look up in all
namespaces or in a specific one. If an export item is accompanied by an
explicit namespace specifier `type` or `data`, we restrict the lookup in
`lookupGRE` to a specific namespace.
The newly introduced diagnostic `TcRnExportedSubordinateNotFound`
provides error messages and suggestions more tailored to this context
than the previously used `reportUnboundName`.
- - - - -
f75ab223 by Peter Trommler at 2025-10-31T18:43:13-04:00
ghc-toolchain: detect PowerPC 64 bit ABI
Check preprocessor macro defined for ABI v2 and assume v1 otherwise.
Fixes #26521
- - - - -
d086c474 by Peter Trommler at 2025-10-31T18:43:13-04:00
ghc-toolchain: refactor, move lastLine to Utils
- - - - -
995dfe0d by Vladislav Zavialov at 2025-10-31T18:43:54-04:00
Tests for -Wduplicate-exports, -Wdodgy-exports
Add test cases for the previously untested diagnostics:
[GHC-51876] TcRnDupeModuleExport
[GHC-64649] TcRnNullExportedModule
This also revealed a typo (incorrect capitalization of "module") in the
warning text for TcRnDupeModuleExport, which is now fixed.
- - - - -
f6961b02 by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: reformat dyld source code
This commit reformats dyld source code with prettier, to avoid
introducing unnecessary diffs in subsequent patches when they're
formatted before committing.
- - - - -
0c9032a0 by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: simplify _initialize logic in dyld
This commit simplifies how we _initialize a wasm shared library in
dyld and removes special treatment for libc.so, see added comment for
detailed explanation.
- - - - -
ec1b40bd by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: support running dyld fully client side in the browser
This commit refactors the wasm dyld script so that it can be used to
load and run wasm shared libraries fully client-side in the browser
without needing a wasm32-wasi-ghci backend:
- A new `DyLDBrowserHost` class is exported, which runs in the browser
and uses the in-memory vfs without any RPC calls. This meant to be
used to create a `rpc` object for the fully client side use cases.
- The exported `main` function now can be used to load user-specified
shared libraries, and the user can use the returned `DyLD` instance
to run their own exported Haskell functions.
- The in-browser wasi implementation is switched to
https://github.com/haskell-wasm/browser_wasi_shim for bugfixes and
major performance improvements not landed upstream yet.
- When being run by deno, it now correctly switches to non-nodejs code
paths, so it's more convenient to test dyld logic with deno.
See added comments for details, as well as the added `playground001`
test case for an example of using it to build an in-browser Haskell
playground.
- - - - -
8f3e481f by Cheng Shao at 2025-11-01T00:08:01+01:00
testsuite: add playground001 to test haskell playground
This commit adds the playground001 test case to test the haskell
playground in browser, see comments for details.
- - - - -
af40606a by Cheng Shao at 2025-11-01T00:08:04+01:00
Revert "testsuite: add T26431 test case"
This reverts commit 695036686f8c6d78611edf3ed627608d94def6b7. T26431
is now retired, wasm ghc internal-interpreter logic is tested by
playground001.
- - - - -
86c82745 by Vladislav Zavialov at 2025-11-01T07:24:29-04:00
Supplant TcRnExportHiddenComponents with TcRnDodgyExports (#26534)
Remove a bogus special case in lookup_ie_kids_all,
making TcRnExportHiddenComponents obsolete.
- - - - -
69f750a6 by Simon Peyton Jones at 2025-11-02T23:41:41+00:00
Start at moving static forms straight to top level
Just for CI. Needs documentation.
- - - - -
580a4723 by Simon Peyton Jones at 2025-11-02T23:41:42+00:00
Wibble
- - - - -
07a053cb by Simon Peyton Jones at 2025-11-02T23:41:42+00:00
Fix desugaring
- - - - -
158 changed files:
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/CmmToC.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/ConLike.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Hs.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Foreign/Wasm.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc/Utils.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Types.hs
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Linker/Linker.hs
- compiler/GHC/StgToJS/Prim.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Deriv/Generics.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/Unique/FM.hs
- compiler/GHC/Types/Var/Env.hs
- compiler/Language/Haskell/Syntax/Expr.hs
- docs/users_guide/9.16.1-notes.rst
- hadrian/src/Rules/Gmp.hs
- hadrian/src/Rules/Libffi.hs
- hadrian/src/Settings/Builders/Cabal.hs
- hadrian/src/Settings/Builders/Common.hs
- hadrian/src/Settings/Builders/DeriveConstants.hs
- hadrian/src/Settings/Builders/Hsc2Hs.hs
- libraries/base/src/GHC/Base.hs
- libraries/base/src/GHC/Exts.hs
- libraries/ghc-experimental/CHANGELOG.md
- libraries/ghc-internal/cbits/Stack_c.c
- libraries/ghc-internal/ghc-internal.cabal.in
- + libraries/ghc-internal/src/GHC/Internal/Stack/ConstantsProf.hsc
- libraries/ghc-internal/src/GHC/Internal/Stack/Decode.hs
- + libraries/ghc-internal/tests/backtraces/T26507.hs
- + libraries/ghc-internal/tests/backtraces/T26507.stderr
- libraries/ghc-internal/tests/backtraces/all.T
- libraries/ghc-internal/tests/stack-annotation/all.T
- libraries/ghc-prim/changelog.md
- m4/fp_check_pthreads.m4
- rts/configure.ac
- + rts/rts.buildinfo.in
- rts/rts.cabal
- testsuite/tests/diagnostic-codes/codes.stdout
- + testsuite/tests/ghc-api-browser/README.md
- + testsuite/tests/ghc-api-browser/all.T
- + testsuite/tests/ghc-api-browser/index.html
- + testsuite/tests/ghc-api-browser/playground001.hs
- + testsuite/tests/ghc-api-browser/playground001.js
- + testsuite/tests/ghc-api-browser/playground001.sh
- testsuite/tests/ghci-wasm/T26431.stdout → testsuite/tests/ghc-api-browser/playground001.stdout
- − testsuite/tests/ghci-wasm/T26431.hs
- testsuite/tests/ghci-wasm/all.T
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/linters/all.T
- testsuite/tests/module/mod4.stderr
- + testsuite/tests/overloadedrecflds/should_fail/T26480.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26480.stderr
- + testsuite/tests/overloadedrecflds/should_fail/T26480_aux1.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26480_aux2.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26480b.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
- testsuite/tests/overloadedrecflds/should_fail/all.T
- testsuite/tests/overloadedrecflds/should_fail/hasfieldfail01.stderr
- testsuite/tests/overloadedrecflds/should_fail/hasfieldfail02.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.hs
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- + testsuite/tests/parser/should_fail/T12488c.hs
- + testsuite/tests/parser/should_fail/T12488c.stderr
- + testsuite/tests/parser/should_fail/T12488d.hs
- + testsuite/tests/parser/should_fail/T12488d.stderr
- testsuite/tests/parser/should_fail/all.T
- + testsuite/tests/perf/compiler/T26425.hs
- testsuite/tests/perf/compiler/all.T
- + testsuite/tests/rename/should_compile/T12488b.hs
- + testsuite/tests/rename/should_compile/T12488f.hs
- testsuite/tests/rename/should_compile/all.T
- + testsuite/tests/rename/should_fail/T12488a.hs
- + testsuite/tests/rename/should_fail/T12488a.stderr
- + testsuite/tests/rename/should_fail/T12488a_foo.hs
- + testsuite/tests/rename/should_fail/T12488a_foo.stderr
- + testsuite/tests/rename/should_fail/T12488e.hs
- + testsuite/tests/rename/should_fail/T12488e.stderr
- + testsuite/tests/rename/should_fail/T12488g.hs
- + testsuite/tests/rename/should_fail/T12488g.stderr
- testsuite/tests/rename/should_fail/T19843h.stderr
- testsuite/tests/rename/should_fail/T25899e2.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/simd/should_run/all.T
- + testsuite/tests/simd/should_run/simd015.hs
- + testsuite/tests/simd/should_run/simd015.stdout
- + testsuite/tests/simd/should_run/simd016.hs
- + testsuite/tests/simd/should_run/simd016.stdout
- + testsuite/tests/simd/should_run/simd017.hs
- + testsuite/tests/simd/should_run/simd017.stdout
- + testsuite/tests/typecheck/should_compile/T17705.hs
- testsuite/tests/typecheck/should_compile/all.T
- + testsuite/tests/warnings/should_compile/DodgyExports02.hs
- + testsuite/tests/warnings/should_compile/DodgyExports02.stderr
- + testsuite/tests/warnings/should_compile/DodgyExports03.hs
- + testsuite/tests/warnings/should_compile/DodgyExports03.stderr
- + testsuite/tests/warnings/should_compile/DuplicateModExport.hs
- + testsuite/tests/warnings/should_compile/DuplicateModExport.stderr
- + testsuite/tests/warnings/should_compile/EmptyModExport.hs
- + testsuite/tests/warnings/should_compile/EmptyModExport.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/check-exact/ExactPrint.hs
- utils/ghc-toolchain/ghc-toolchain.cabal
- utils/ghc-toolchain/src/GHC/Toolchain/CheckArm.hs
- + utils/ghc-toolchain/src/GHC/Toolchain/CheckPower.hs
- utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/jsffi/dyld.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a4da0bb5460887faa1cd86421113c…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a4da0bb5460887faa1cd86421113c…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/T26514] 24 commits: Fix stack decoding when using profiled runtime
by Simon Peyton Jones (@simonpj) 02 Nov '25
by Simon Peyton Jones (@simonpj) 02 Nov '25
02 Nov '25
Simon Peyton Jones pushed to branch wip/T26514 at Glasgow Haskell Compiler / GHC
Commits:
38d65187 by Matthew Pickering at 2025-10-21T13:12:20+01:00
Fix stack decoding when using profiled runtime
There are three fixes in this commit.
* We need to replicate the `InfoTable` and `InfoTableProf`
approach for the other stack constants (see the new Stack.ConstantsProf
file).
* Then we need to appropiately import the profiled or non-profiled
versions.
* Finally, there was an incorrect addition in `stackFrameSize`. We need
to cast after performing addition on words.
Fixes #26507
- - - - -
17231bfb by fendor at 2025-10-21T13:12:20+01:00
Add regression test for #26507
- - - - -
4f5bf93b by Simon Peyton Jones at 2025-10-25T04:05:34-04:00
Postscript to fix for #26255
This MR has comments only
- - - - -
6ef22fa0 by IC Rainbow at 2025-10-26T18:23:01-04:00
Add SIMD primops for bitwise logical operations
This adds 128-bit wide and/or/xor instructions for X86 NCG,
with both SSE and AVX encodings.
```
andFloatX4# :: FloatX4# -> FloatX4# -> FloatX4# -- andps / vandps
andDoubleX2# :: DoubleX2# -> DoubleX2# -> DoubleX2# -- andpd / vandpd
andInt8X16# :: Int8X16# -> Int8X16# -> Int8X16# -- pand / vpand
```
The new primops are available on ARM when using LLVM backend.
Tests added:
- simd015 (floats and doubles)
- simd016 (integers)
- simd017 (words)
Fixes #26417
- - - - -
fbdc623a by sheaf at 2025-10-26T18:23:52-04:00
Add hints for unsolved HasField constraints
This commit adds hints and explanations for unsolved 'HasField'
constraints.
GHC will now provide additional explanations for an unsolved constraint
of the form 'HasField fld_name rec_ty fld_ty'; the details are laid out in
Note [Error messages for unsolved HasField constraints], but briefly:
1. Provide similar name suggestions (e.g. mis-spelled field name)
and import suggestions (record field not in scope).
These result in actionable 'GhcHints', which is helpful to provide
code actions in HLS.
2. Explain why GHC did not solve the constraint, e.g.:
- 'fld_name' is not a string literal (e.g. a type variable)
- 'rec_ty' is a TyCon without any fields, e.g. 'Int' or 'Bool'.
- 'fld_ty' contains existentials variables or foralls.
- The record field is a pattern synonym field (GHC does not generate
HasField instances for those).
- 'HasField' is a custom 'TyCon', not actually the built-in
'HasField' typeclass from 'GHC.Records'.
On the way, we slightly refactor the mechanisms for import suggestions
in GHC.Rename.Unbound. This is to account for the fact that, for
'HasField', we don't care whether the field is imported qualified or
unqualified. 'importSuggestions' was refactored, we now have
'sameQualImportSuggestions' and 'anyQualImportSuggestions'.
Fixes #18776 #22382 #26480
- - - - -
99d5707f by sheaf at 2025-10-26T18:23:52-04:00
Rename PatSyn MatchContext to PatSynCtx to avoid punning
- - - - -
5dc2e9ea by Julian Ospald at 2025-10-27T18:17:23-04:00
Skip uniques test if sources are not available
- - - - -
544b9ec9 by Vladislav Zavialov at 2025-10-27T18:18:06-04:00
Re-export GHC.Hs.Basic from GHC.Hs
Clean up some import sections in GHC by re-exporting GHC.Hs.Basic
from GHC.Hs.
- - - - -
643ce801 by Julian Ospald at 2025-10-28T18:18:55-04:00
rts: remove unneccesary cabal flags
We perform those checks via proper autoconf macros
instead that do the right thing and then add those
libs to the rts buildinfo.
- - - - -
d69ea8fe by Vladislav Zavialov at 2025-10-28T18:19:37-04:00
Test case for #17705
Starting with GHC 9.12 (the first release to include 5745dbd3),
all examples in this ticket are handled as expected.
- - - - -
4038a28b by Andreas Klebinger at 2025-10-30T12:38:52-04:00
Add a perf test for #26425
- - - - -
f997618e by Andreas Klebinger at 2025-10-30T12:38:52-04:00
OccAnal: Be stricter for better compiler perf.
In particular we are now stricter:
* When combining usageDetails.
* When computing binder info.
In combineUsageDetails when combining the underlying adds we compute a
new `LocalOcc` for each entry by combining the two existing ones.
Rather than wait for those entries to be forced down the road we now
force them immediately. Speeding up T26425 by about 10% with little
effect on the common case.
We also force binders we put into the Core AST everywhere now.
Failure to do so risks leaking the occ env used to set the binders
OccInfo.
For T26425 compiler residency went down by a factor of ~10x.
Compile time also improved by a factor of ~1.6.
-------------------------
Metric Decrease:
T18698a
T26425
T9233
-------------------------
- - - - -
5618645b by Vladislav Zavialov at 2025-10-30T12:39:33-04:00
Fix namespace specifiers in subordinate exports (#12488)
This patch fixes an oversight in the `lookupChildrenExport` function that
caused explicit namespace specifiers of subordinate export items to be
ignored:
module M (T (type A)) where -- should be rejected
data T = A
Based on the `IEWrappedName` data type, there are 5 cases to consider:
1. Unadorned name: P(X)
2. Named default: P(default X)
3. Pattern synonym: P(pattern X)
4. Type name: P(type X)
5. Data name: P(data X)
Case 1 is already handled correctly; cases 2 and 3 are parse errors; and
it is cases 4 and 5 that we are concerned with in this patch.
Following the precedent established in `LookupExactName`, we introduce
a boolean flag in `LookupChildren` to control whether to look up in all
namespaces or in a specific one. If an export item is accompanied by an
explicit namespace specifier `type` or `data`, we restrict the lookup in
`lookupGRE` to a specific namespace.
The newly introduced diagnostic `TcRnExportedSubordinateNotFound`
provides error messages and suggestions more tailored to this context
than the previously used `reportUnboundName`.
- - - - -
f75ab223 by Peter Trommler at 2025-10-31T18:43:13-04:00
ghc-toolchain: detect PowerPC 64 bit ABI
Check preprocessor macro defined for ABI v2 and assume v1 otherwise.
Fixes #26521
- - - - -
d086c474 by Peter Trommler at 2025-10-31T18:43:13-04:00
ghc-toolchain: refactor, move lastLine to Utils
- - - - -
995dfe0d by Vladislav Zavialov at 2025-10-31T18:43:54-04:00
Tests for -Wduplicate-exports, -Wdodgy-exports
Add test cases for the previously untested diagnostics:
[GHC-51876] TcRnDupeModuleExport
[GHC-64649] TcRnNullExportedModule
This also revealed a typo (incorrect capitalization of "module") in the
warning text for TcRnDupeModuleExport, which is now fixed.
- - - - -
f6961b02 by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: reformat dyld source code
This commit reformats dyld source code with prettier, to avoid
introducing unnecessary diffs in subsequent patches when they're
formatted before committing.
- - - - -
0c9032a0 by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: simplify _initialize logic in dyld
This commit simplifies how we _initialize a wasm shared library in
dyld and removes special treatment for libc.so, see added comment for
detailed explanation.
- - - - -
ec1b40bd by Cheng Shao at 2025-11-01T00:08:01+01:00
wasm: support running dyld fully client side in the browser
This commit refactors the wasm dyld script so that it can be used to
load and run wasm shared libraries fully client-side in the browser
without needing a wasm32-wasi-ghci backend:
- A new `DyLDBrowserHost` class is exported, which runs in the browser
and uses the in-memory vfs without any RPC calls. This meant to be
used to create a `rpc` object for the fully client side use cases.
- The exported `main` function now can be used to load user-specified
shared libraries, and the user can use the returned `DyLD` instance
to run their own exported Haskell functions.
- The in-browser wasi implementation is switched to
https://github.com/haskell-wasm/browser_wasi_shim for bugfixes and
major performance improvements not landed upstream yet.
- When being run by deno, it now correctly switches to non-nodejs code
paths, so it's more convenient to test dyld logic with deno.
See added comments for details, as well as the added `playground001`
test case for an example of using it to build an in-browser Haskell
playground.
- - - - -
8f3e481f by Cheng Shao at 2025-11-01T00:08:01+01:00
testsuite: add playground001 to test haskell playground
This commit adds the playground001 test case to test the haskell
playground in browser, see comments for details.
- - - - -
af40606a by Cheng Shao at 2025-11-01T00:08:04+01:00
Revert "testsuite: add T26431 test case"
This reverts commit 695036686f8c6d78611edf3ed627608d94def6b7. T26431
is now retired, wasm ghc internal-interpreter logic is tested by
playground001.
- - - - -
86c82745 by Vladislav Zavialov at 2025-11-01T07:24:29-04:00
Supplant TcRnExportHiddenComponents with TcRnDodgyExports (#26534)
Remove a bogus special case in lookup_ie_kids_all,
making TcRnExportHiddenComponents obsolete.
- - - - -
3eb15c6d by Simon Peyton Jones at 2025-11-02T20:29:44+00:00
Wibble [skip ci]
- - - - -
216a943c by Simon Peyton Jones at 2025-11-02T20:29:44+00:00
Make PmLit be in Ord
... so that we can use a finite map instead of a list
Let's see if ther are any perf changes
- - - - -
149 changed files:
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/CmmToC.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/ConLike.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Hs.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/HsToCore/Foreign/Wasm.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/HsToCore/Pmc/Utils.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Prim.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Deriv/Generics.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Name/Reader.hs
- compiler/GHC/Types/SourceText.hs
- compiler/GHC/Types/Unique/FM.hs
- compiler/GHC/Types/Var/Env.hs
- compiler/Language/Haskell/Syntax/Expr.hs
- docs/users_guide/9.16.1-notes.rst
- libraries/base/src/GHC/Base.hs
- libraries/base/src/GHC/Exts.hs
- libraries/ghc-experimental/CHANGELOG.md
- libraries/ghc-internal/cbits/Stack_c.c
- libraries/ghc-internal/ghc-internal.cabal.in
- + libraries/ghc-internal/src/GHC/Internal/Stack/ConstantsProf.hsc
- libraries/ghc-internal/src/GHC/Internal/Stack/Decode.hs
- + libraries/ghc-internal/tests/backtraces/T26507.hs
- + libraries/ghc-internal/tests/backtraces/T26507.stderr
- libraries/ghc-internal/tests/backtraces/all.T
- libraries/ghc-internal/tests/stack-annotation/all.T
- libraries/ghc-prim/changelog.md
- m4/fp_check_pthreads.m4
- rts/configure.ac
- + rts/rts.buildinfo.in
- rts/rts.cabal
- testsuite/tests/diagnostic-codes/codes.stdout
- + testsuite/tests/ghc-api-browser/README.md
- + testsuite/tests/ghc-api-browser/all.T
- + testsuite/tests/ghc-api-browser/index.html
- + testsuite/tests/ghc-api-browser/playground001.hs
- + testsuite/tests/ghc-api-browser/playground001.js
- + testsuite/tests/ghc-api-browser/playground001.sh
- testsuite/tests/ghci-wasm/T26431.stdout → testsuite/tests/ghc-api-browser/playground001.stdout
- − testsuite/tests/ghci-wasm/T26431.hs
- testsuite/tests/ghci-wasm/all.T
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/linters/all.T
- testsuite/tests/module/mod4.stderr
- + testsuite/tests/overloadedrecflds/should_fail/T26480.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26480.stderr
- + testsuite/tests/overloadedrecflds/should_fail/T26480_aux1.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26480_aux2.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26480b.hs
- + testsuite/tests/overloadedrecflds/should_fail/T26480b.stderr
- testsuite/tests/overloadedrecflds/should_fail/all.T
- testsuite/tests/overloadedrecflds/should_fail/hasfieldfail01.stderr
- testsuite/tests/overloadedrecflds/should_fail/hasfieldfail02.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.hs
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr
- + testsuite/tests/parser/should_fail/T12488c.hs
- + testsuite/tests/parser/should_fail/T12488c.stderr
- + testsuite/tests/parser/should_fail/T12488d.hs
- + testsuite/tests/parser/should_fail/T12488d.stderr
- testsuite/tests/parser/should_fail/all.T
- + testsuite/tests/perf/compiler/T26425.hs
- testsuite/tests/perf/compiler/all.T
- + testsuite/tests/rename/should_compile/T12488b.hs
- + testsuite/tests/rename/should_compile/T12488f.hs
- testsuite/tests/rename/should_compile/all.T
- + testsuite/tests/rename/should_fail/T12488a.hs
- + testsuite/tests/rename/should_fail/T12488a.stderr
- + testsuite/tests/rename/should_fail/T12488a_foo.hs
- + testsuite/tests/rename/should_fail/T12488a_foo.stderr
- + testsuite/tests/rename/should_fail/T12488e.hs
- + testsuite/tests/rename/should_fail/T12488e.stderr
- + testsuite/tests/rename/should_fail/T12488g.hs
- + testsuite/tests/rename/should_fail/T12488g.stderr
- testsuite/tests/rename/should_fail/T19843h.stderr
- testsuite/tests/rename/should_fail/T25899e2.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/simd/should_run/all.T
- + testsuite/tests/simd/should_run/simd015.hs
- + testsuite/tests/simd/should_run/simd015.stdout
- + testsuite/tests/simd/should_run/simd016.hs
- + testsuite/tests/simd/should_run/simd016.stdout
- + testsuite/tests/simd/should_run/simd017.hs
- + testsuite/tests/simd/should_run/simd017.stdout
- + testsuite/tests/typecheck/should_compile/T17705.hs
- testsuite/tests/typecheck/should_compile/all.T
- + testsuite/tests/warnings/should_compile/DodgyExports02.hs
- + testsuite/tests/warnings/should_compile/DodgyExports02.stderr
- + testsuite/tests/warnings/should_compile/DodgyExports03.hs
- + testsuite/tests/warnings/should_compile/DodgyExports03.stderr
- + testsuite/tests/warnings/should_compile/DuplicateModExport.hs
- + testsuite/tests/warnings/should_compile/DuplicateModExport.stderr
- + testsuite/tests/warnings/should_compile/EmptyModExport.hs
- + testsuite/tests/warnings/should_compile/EmptyModExport.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/check-exact/ExactPrint.hs
- utils/ghc-toolchain/ghc-toolchain.cabal
- utils/ghc-toolchain/src/GHC/Toolchain/CheckArm.hs
- + utils/ghc-toolchain/src/GHC/Toolchain/CheckPower.hs
- utils/ghc-toolchain/src/GHC/Toolchain/ParseTriple.hs
- utils/ghc-toolchain/src/GHC/Toolchain/Utils.hs
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/jsffi/dyld.mjs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/962301c632aaf2f9f873346c1de818…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/962301c632aaf2f9f873346c1de818…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
02 Nov '25
Zubin pushed to branch ghc-9.14 at Glasgow Haskell Compiler / GHC
Commits:
b213fd91 by Ben Gamari at 2025-10-31T17:37:45+05:30
Bump exceptions to 0.10.11
- - - - -
5e30da3a by Ben Gamari at 2025-10-31T17:37:45+05:30
Bump os-string to 2.0.8
- - - - -
50353478 by Zubin Duggal at 2025-10-31T17:47:56+05:30
rel-notes: mention #26166
- - - - -
4 changed files:
- docs/users_guide/9.14.1-notes.rst
- libraries/exceptions
- libraries/os-string
- testsuite/tests/ghc-e/should_fail/T9930fail.stderr
Changes:
=====================================
docs/users_guide/9.14.1-notes.rst
=====================================
@@ -209,6 +209,9 @@ Runtime system
flag is not passed, preserving previous behavior.
+- Reorganise how certain symbols are linked to avoid a bootstrapping failure
+ with the linker shipping newer macOS versions (:ghc-ticket:`26166`)
+
``base`` library
~~~~~~~~~~~~~~~~
=====================================
libraries/exceptions
=====================================
@@ -1 +1 @@
-Subproject commit b6c4290124eb1138358bf04ad9f33e67f6c5c1d8
+Subproject commit 81bfd6e0ca631f315658201ae02e30046678f056
=====================================
libraries/os-string
=====================================
@@ -1 +1 @@
-Subproject commit 2e693aad07540173a0169971b27c9acac28eeff1
+Subproject commit c08666bf7bf528e607fc1eacc20032ec59e69df3
=====================================
testsuite/tests/ghc-e/should_fail/T9930fail.stderr
=====================================
@@ -7,5 +7,6 @@ While handling default output name would overwrite the input file; must specify
| Usage: For basic information, try the `--help' option.
HasCallStack backtrace:
- bracket, called at compiler/GHC/Driver/MakeAction.hs:2955:3 in ghc-9.13-inplace:GHC.Driver.MakeAction
-
+ throwIO, called at libraries/exceptions/src/Control/Monad/Catch.hs:1:1 in <package-id>:Control.Monad.Catch
+ throwM, called at libraries/exceptions/src/Control/Monad/Catch.hs:1:1 in <package-id>:Control.Monad.Catch
+ onException, called at compiler/GHC/Driver/MakeAction.hs:1:1 in <package-id>:GHC.Driver.MakeAction
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/02150b65487cb675480ed8697c956f…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/02150b65487cb675480ed8697c956f…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
[Git][ghc/ghc][wip/spj-apporv-Oct24] - Move `PopErrCtxt` into `SrcCodeOrigin`
by Apoorv Ingle (@ani) 02 Nov '25
by Apoorv Ingle (@ani) 02 Nov '25
02 Nov '25
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
dc871fb9 by Apoorv Ingle at 2025-11-02T13:37:09-06:00
- Move `PopErrCtxt` into `SrcCodeOrigin`
- Pass in the location of the head of the application chain to `addArgCtxt` to print better error messages.
Make `addArgCtxt` print in the nth argument if the head of the application chain is user located.
- match context with record updates dont get added in error context
- - - - -
18 changed files:
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Monad.hs
- testsuite/tests/rebindable/rebindable6.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion1.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
Changes:
=====================================
compiler/GHC/Hs/Expr.hs
=====================================
@@ -676,22 +676,22 @@ data SrcCodeOrigin
= OrigExpr (HsExpr GhcRn) -- ^ The source, user written, expression
| OrigStmt (ExprLStmt GhcRn) HsDoFlavour -- ^ which kind of do-block did this statement come from
| OrigPat (Pat GhcRn) -- ^ Used for failable patterns that trigger MonadFail constraints
+ | PopErrCtxt -- A hint for typechecker to pop
+ -- the top of the error context stack
+ -- Does not presist post renaming phase
+ -- See Part 3. of Note [Expanding HsDo with XXExprGhcRn]
+ -- in `GHC.Tc.Gen.Do`
+ -- INVARIANT: SHOULD NEVER APPEAR IN A ExpansionCodeCtxt in CodeSrcFlag ErrCtxt on stack
data XXExprGhcRn
= ExpandedThingRn { xrn_orig :: SrcCodeOrigin -- The original source thing to be used for error messages
, xrn_expanded :: HsExpr GhcRn -- The compiler generated, expanded thing
}
- | PopErrCtxt -- A hint for typechecker to pop
- {-# UNPACK #-} !(HsExpr GhcRn) -- the top of the error context stack
- -- Does not presist post renaming phase
- -- See Part 3. of Note [Expanding HsDo with XXExprGhcRn]
- -- in `GHC.Tc.Gen.Do`
| HsRecSelRn (FieldOcc GhcRn) -- ^ Variable pointing to record selector
-- See Note [Non-overloaded record field selectors] and
-- Note [Record selectors in the AST]
-
-- | Build an expression using the extension constructor `XExpr`,
-- and the two components of the expansion: original expression and
-- expanded expressions.
@@ -713,6 +713,12 @@ mkExpandedStmt
mkExpandedStmt oStmt flav eExpr = XExpr (ExpandedThingRn { xrn_orig = OrigStmt oStmt flav
, xrn_expanded = eExpr })
+mkExpandedLastStmt
+ :: HsExpr GhcRn -- ^ expanded expression
+ -> HsExpr GhcRn -- ^ suitably wrapped 'XXExprGhcRn'
+mkExpandedLastStmt eExpr = XExpr (ExpandedThingRn { xrn_orig = PopErrCtxt
+ , xrn_expanded = eExpr })
+
data XXExprGhcTc
= WrapExpr -- Type and evidence application and abstractions
HsWrapper (HsExpr GhcTc)
@@ -1083,11 +1089,11 @@ instance Outputable SrcCodeOrigin where
OrigExpr x -> ppr_builder "<OrigExpr>:" x
OrigStmt x _ -> ppr_builder "<OrigStmt>:" x
OrigPat x -> ppr_builder "<OrigPat>:" x
+ PopErrCtxt -> text "<PopErrCtxt>"
where ppr_builder prefix x = ifPprDebug (braces (text prefix <+> parens (ppr x))) (ppr x)
instance Outputable XXExprGhcRn where
ppr (ExpandedThingRn o e) = ifPprDebug (braces $ vcat [ppr o, text ";;" , ppr e]) (ppr o)
- ppr (PopErrCtxt e) = ifPprDebug (braces (text "<PopErrCtxt>" <+> ppr e)) (ppr e)
ppr (HsRecSelRn f) = pprPrefixOcc f
instance Outputable XXExprGhcTc where
@@ -1133,7 +1139,6 @@ ppr_infix_expr _ = Nothing
ppr_infix_expr_rn :: XXExprGhcRn -> Maybe SDoc
ppr_infix_expr_rn (ExpandedThingRn thing _) = ppr_infix_hs_expansion thing
-ppr_infix_expr_rn (PopErrCtxt a) = ppr_infix_expr a
ppr_infix_expr_rn (HsRecSelRn f) = Just (pprInfixOcc f)
ppr_infix_expr_tc :: XXExprGhcTc -> Maybe SDoc
@@ -1233,7 +1238,6 @@ hsExprNeedsParens prec = go
go_x_rn :: XXExprGhcRn -> Bool
go_x_rn (ExpandedThingRn thing _ ) = hsExpandedNeedsParens thing
- go_x_rn (PopErrCtxt a) = hsExprNeedsParens prec a
go_x_rn (HsRecSelRn{}) = False
hsExpandedNeedsParens :: SrcCodeOrigin -> Bool
@@ -1286,7 +1290,6 @@ isAtomicHsExpr (XExpr x)
go_x_rn :: XXExprGhcRn -> Bool
go_x_rn (ExpandedThingRn thing _) = isAtomicExpandedThingRn thing
- go_x_rn (PopErrCtxt a) = isAtomicHsExpr a
go_x_rn (HsRecSelRn{}) = True
isAtomicExpandedThingRn :: SrcCodeOrigin -> Bool
=====================================
compiler/GHC/HsToCore/Quote.hs
=====================================
@@ -1744,7 +1744,6 @@ repE e@(XExpr (ExpandedThingRn o x))
else repE e }
| otherwise
= notHandled (ThExpressionForm e)
-repE (XExpr (PopErrCtxt e)) = repE e
repE (XExpr (HsRecSelRn (FieldOcc _ (L _ x)))) = repE (mkHsVar (noLocA x))
repE e@(HsPragE _ (HsPragSCC {}) _) = notHandled (ThCostCentres e)
repE e@(HsTypedBracket{}) = notHandled (ThExpressionForm e)
=====================================
compiler/GHC/Rename/Utils.hs
=====================================
@@ -20,7 +20,7 @@ module GHC.Rename.Utils (
DeprecationWarnings(..), warnIfDeprecated,
checkUnusedRecordWildcard,
badQualBndrErr, typeAppErr, badFieldConErr,
- wrapGenSpan, genHsVar, genLHsVar, genHsApp, genHsApps, genHsApps', genHsExpApps,
+ wrapGenSpan, wrapNoSpan, genHsVar, genLHsVar, genHsApp, genHsApps, genHsApps', genHsExpApps,
genLHsApp, genAppType,
genLHsLit, genHsIntegralLit, genHsTyLit, genSimpleConPat,
genVarPat, genWildPat,
@@ -705,6 +705,12 @@ wrapGenSpan :: (HasAnnotation an) => a -> GenLocated an a
-- See Note [Rebindable syntax and XXExprGhcRn]
wrapGenSpan x = L (noAnnSrcSpan generatedSrcSpan) x
+wrapNoSpan :: (HasAnnotation an) => a -> GenLocated an a
+-- Wrap something in a "noSrcSpan"
+-- See Note [Rebindable syntax and XXExprGhcRn]
+wrapNoSpan x = L (noAnnSrcSpan noSrcSpan) x
+
+
-- | Make a 'SyntaxExpr' from a 'Name' (the "rn" is because this is used in the
-- renamer).
mkRnSyntaxExpr :: Name -> SyntaxExprRn
=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -26,10 +26,6 @@ import GHC.Driver.Config.Diagnostic
import GHC.Rename.Unbound
-import Language.Haskell.Syntax (DotFieldOcc (..))
-import Language.Haskell.Syntax.Basic (FieldLabelString (..))
-import GHC.Hs.Expr (SrcCodeOrigin (..), HsExpr (..))
-
import GHC.Tc.Types
import GHC.Tc.Utils.Monad
import GHC.Tc.Errors.Types
@@ -2394,43 +2390,6 @@ mk_dict_err ctxt (item, (matches, pot_unifiers, unsafe_overlapped))
in different_names && same_occ_names
| otherwise = False
- -- See Note [Out-of-scope fields with -XOverloadedRecordDot]
- record_field_suggestions :: ErrorItem -> TcM ([ImportError], [GhcHint])
- record_field_suggestions item = flip (maybe $ return ([], noHints)) record_field $ \name ->
- do { glb_env <- getGlobalRdrEnv
- ; lcl_env <- getLocalRdrEnv
- ; let field_name_hints = report_no_fieldnames item
- ; (errs, hints) <- if occ_name_in_scope glb_env lcl_env name
- then return ([], noHints)
- else unknownNameSuggestions emptyLocalRdrEnv WL_RecField (mkRdrUnqual name)
- ; pure (errs, hints ++ field_name_hints)
- }
-
- -- get type names from instance
- -- resolve the type - if it's in scope is it a record?
- -- if it's a record, report an error - the record name + the field that could not be found
- report_no_fieldnames :: ErrorItem -> [GhcHint]
- report_no_fieldnames item
- | Just (EvVarDest evvar) <- ei_evdest item
- -- we can assume that here we have a `HasField @Symbol x r a` instance
- -- because of GetFieldOrigin in record_field
- , Just (_, [_symbol, x, r, a]) <- tcSplitTyConApp_maybe (varType evvar)
- , Just (r_tycon, _) <- tcSplitTyConApp_maybe r
- , Just x_name <- isStrLitTy x
- -- we check that this is a record type by checking whether it has any
- -- fields (in scope)
- , not . null $ tyConFieldLabels r_tycon
- = [RemindRecordMissingField x_name r a]
- | otherwise = []
-
- occ_name_in_scope glb_env lcl_env occ_name = not $
- null (lookupGRE glb_env (LookupOccName occ_name (RelevantGREsFOS WantNormal))) &&
- isNothing (lookupLocalRdrOcc lcl_env occ_name)
-
- record_field = case orig of
- ExpansionOrigin (OrigExpr (HsGetField _ _ (L _ name))) -> Just (mkVarOccFS (field_label $ unLoc $ dfoLabel name))
- _ -> Nothing
-
{- Note [Report candidate instances]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If we have an unsolved (Num Int), where `Int` is not the Prelude Int,
=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -7564,10 +7564,6 @@ pprTyConInstFlavour
pprErrCtxtMsg :: ErrCtxtMsg -> SDoc
pprErrCtxtMsg = \case
ExprCtxt expr
- | XExpr (ExpandedThingRn (OrigStmt (L _ stmt) flav) _) <- expr
- -> hang (text "In a stmt of" <+> pprAStmtContext @(LIdP GhcRn) (HsDoStmt flav) <> colon)
- 2 (ppr_stmt stmt)
- | otherwise
-> hang (text "In the expression:")
2 (ppr (stripParensHsExpr expr))
ThetaCtxt ctxt theta ->
=====================================
compiler/GHC/Tc/Gen/App.hs
=====================================
@@ -32,7 +32,8 @@ import GHC.Tc.Gen.HsType
import GHC.Tc.Utils.Concrete ( unifyConcrete, idConcreteTvs )
import GHC.Tc.Utils.TcMType
import GHC.Tc.Types.Evidence
-import GHC.Tc.Types.ErrCtxt ( FunAppCtxtFunArg(..) )
+import GHC.Tc.Types.ErrCtxt ( FunAppCtxtFunArg(..), ErrCtxt (..), CodeSrcFlag (..))
+import GHC.Tc.Errors.Ppr (pprErrCtxtMsg)
import GHC.Tc.Types.Origin
import GHC.Tc.Utils.TcType as TcType
import GHC.Tc.Utils.Concrete( hasFixedRuntimeRep_syntactic )
@@ -173,6 +174,9 @@ Note [Instantiation variables are short lived]
-- CAUTION: Any changes to tcApp should be reflected here
-- cf. T19167. the head is an expanded expression applied to a type
-- TODO: Use runInfer for tcExprSigma?
+-- Caution: Currently we assume that the expression is compiler generated/expanded
+-- Becuase that is that T19167 testcase generates. This function can possibly
+-- take in the rn_expr and its location to pass into tcValArgs
tcExprSigma :: Bool -> HsExpr GhcRn -> TcM (HsExpr GhcTc, TcSigmaType)
tcExprSigma inst rn_expr
= do { (fun@(rn_fun,fun_ctxt), rn_args) <- splitHsApps rn_expr
@@ -181,7 +185,7 @@ tcExprSigma inst rn_expr
; code_orig <- getSrcCodeOrigin
; let fun_orig = srcCodeOriginCtOrigin rn_expr code_orig
; (inst_args, app_res_sigma) <- tcInstFun do_ql inst fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
- ; tc_args <- tcValArgs do_ql rn_fun inst_args
+ ; tc_args <- tcValArgs do_ql (rn_fun, generatedSrcSpan) inst_args
; let tc_expr = rebuildHsApps (tc_fun, fun_ctxt) tc_args
; return (tc_expr, app_res_sigma) }
@@ -394,16 +398,18 @@ tcApp :: HsExpr GhcRn
-- See Note [tcApp: typechecking applications]
tcApp rn_expr exp_res_ty
= do { -- Step 1: Split the application chain
- (fun@(rn_fun, fun_loc), rn_args) <- splitHsApps rn_expr
+ (fun@(rn_fun, fun_lspan), rn_args) <- splitHsApps rn_expr
+ ; inGenCode <- inGeneratedCode
; traceTc "tcApp {" $
- vcat [ text "rn_expr:" <+> ppr rn_expr
+ vcat [ text "generated? " <+> ppr inGenCode
+ , text "rn_expr:" <+> ppr rn_expr
, text "rn_fun:" <+> ppr rn_fun
- , text "fun_loc:" <+> ppr fun_loc
+ , text "fun_lspan:" <+> ppr fun_lspan
, text "rn_args:" <+> ppr rn_args ]
-- Step 2: Infer the type of `fun`, the head of the application
; (tc_fun, fun_sigma) <- tcInferAppHead fun
- ; let tc_head = (tc_fun, fun_loc)
+ ; let tc_head = (tc_fun, fun_lspan)
-- inst_final: top-instantiate the result type of the application,
-- EXCEPT if we are trying to infer a sigma-type
inst_final = case exp_res_ty of
@@ -434,7 +440,7 @@ tcApp rn_expr exp_res_ty
, text "fun_origin" <+> ppr fun_orig
, text "do_ql:" <+> ppr do_ql]
; (inst_args, app_res_rho)
- <- tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_loc) fun_sigma rn_args
+ <- tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
-- See (TCAPP1) and (TCAPP2) in
-- Note [tcApp: typechecking applications]
@@ -447,7 +453,7 @@ tcApp rn_expr exp_res_ty
app_res_rho exp_res_ty
-- Step 4.2: typecheck the arguments
- ; tc_args <- tcValArgs NoQL rn_fun inst_args
+ ; tc_args <- tcValArgs NoQL (rn_fun, fun_lspan) inst_args
-- Step 4.3: wrap up
; finishApp tc_head tc_args app_res_rho res_wrap }
@@ -458,7 +464,7 @@ tcApp rn_expr exp_res_ty
-- Step 5.2: typecheck the arguments, and monomorphise
-- any un-unified instantiation variables
- ; tc_args <- tcValArgs DoQL rn_fun inst_args
+ ; tc_args <- tcValArgs DoQL (rn_fun, fun_lspan) inst_args
-- Step 5.3: zonk to expose the polymorphism hidden under
-- QuickLook instantiation variables in `app_res_rho`
; app_res_rho <- liftZonkM $ zonkTcType app_res_rho
@@ -545,16 +551,16 @@ checkResultTy rn_expr (tc_fun, fun_loc) inst_args app_res_rho (Check res_ty)
thing_inside
----------------
-tcValArgs :: QLFlag -> HsExpr GhcRn -> [HsExprArg 'TcpInst] -> TcM [HsExprArg 'TcpTc]
+tcValArgs :: QLFlag -> (HsExpr GhcRn, SrcSpan) -> [HsExprArg 'TcpInst] -> TcM [HsExprArg 'TcpTc]
-- Importantly, tcValArgs works left-to-right, so that by the time we
-- encounter an argument, we have monomorphised all the instantiation
-- variables that its type contains. All that is left to do is an ordinary
-- zonkTcType. See Note [Monomorphise instantiation variables].
-tcValArgs do_ql fun args = go do_ql 0 args
+tcValArgs do_ql (fun, fun_lspan) args = go do_ql 0 args
where
go _ _ [] = return []
go do_ql pos (arg : args) =
- do { arg' <- tcValArg do_ql pos' fun arg
+ do { arg' <- tcValArg do_ql pos' (fun, fun_lspan) arg
; args' <- go do_ql pos' args
; return (arg' : args') }
where
@@ -570,7 +576,7 @@ tcValArgs do_ql fun args = go do_ql 0 args
= pos
-tcValArg :: QLFlag -> Int -> HsExpr GhcRn -> HsExprArg 'TcpInst -- Actual argument
+tcValArg :: QLFlag -> Int -> (HsExpr GhcRn, SrcSpan) -> HsExprArg 'TcpInst -- Actual argument
-> TcM (HsExprArg 'TcpTc) -- Resulting argument
tcValArg _ _ _ (EPrag l p) = return (EPrag l (tcExprPrag p))
tcValArg _ _ _ (ETypeArg l hty ty) = return (ETypeArg l hty ty)
@@ -579,10 +585,10 @@ tcValArg do_ql _ _ (EWrap (EHsWrap w)) = do { whenQL do_ql $ qlMonoHsWrapper w
-- qlMonoHsWrapper: see Note [Monomorphise instantiation variables]
tcValArg _ _ _ (EWrap ew) = return (EWrap ew)
-tcValArg do_ql pos fun (EValArg { ea_loc_span = ctxt
+tcValArg do_ql pos (fun, fun_lspan) (EValArg { ea_loc_span = lspan
, ea_arg = larg@(L arg_loc arg)
, ea_arg_ty = sc_arg_ty })
- = addArgCtxt pos fun larg $
+ = addArgCtxt pos (fun, fun_lspan) larg $
do { -- Crucial step: expose QL results before checking exp_arg_ty
-- So far as the paper is concerned, this step applies
-- the poly-substitution Theta, learned by QL, so that we
@@ -596,7 +602,8 @@ tcValArg do_ql pos fun (EValArg { ea_loc_span = ctxt
DoQL -> liftZonkM $ zonkScaledTcType sc_arg_ty
NoQL -> return sc_arg_ty
; traceTc "tcValArg {" $
- vcat [ text "ctxt:" <+> ppr ctxt
+ vcat [ text "lspan:" <+> ppr lspan
+ , text "fun_lspan" <+> ppr fun_lspan
, text "sigma_type" <+> ppr (mkCheckExpType exp_arg_ty)
, text "arg:" <+> ppr larg
]
@@ -607,13 +614,13 @@ tcValArg do_ql pos fun (EValArg { ea_loc_span = ctxt
tcPolyExpr arg (mkCheckExpType exp_arg_ty)
; traceTc "tcValArg" $ vcat [ ppr arg'
, text "}" ]
- ; return (EValArg { ea_loc_span = ctxt
+ ; return (EValArg { ea_loc_span = lspan
, ea_arg = L arg_loc arg'
, ea_arg_ty = noExtField }) }
-tcValArg _ pos fun (EValArgQL {
+tcValArg _ pos (fun, fun_lspan) (EValArgQL {
eaql_wanted = wanted
- , eaql_loc_span = ctxt
+ , eaql_loc_span = lspan
, eaql_arg_ty = sc_arg_ty
, eaql_larg = larg@(L arg_loc rn_expr)
, eaql_tc_fun = tc_head
@@ -622,7 +629,7 @@ tcValArg _ pos fun (EValArgQL {
, eaql_args = inst_args
, eaql_encl = arg_influences_enclosing_call
, eaql_res_rho = app_res_rho })
- = addArgCtxt pos fun larg $
+ = addArgCtxt pos (fun, fun_lspan) larg $
do { -- Expose QL results to tcSkolemise, as in EValArg case
Scaled mult exp_arg_ty <- liftZonkM $ zonkScaledTcType sc_arg_ty
@@ -631,6 +638,8 @@ tcValArg _ pos fun (EValArgQL {
, text "args:" <+> ppr inst_args
, text "mult:" <+> ppr mult
, text "fun" <+> ppr fun
+ , text "app_lspan" <+> ppr lspan
+ , text "head_lspan" <+> ppr fun_lspan
, text "tc_head" <+> ppr tc_head])
; ds_flag <- getDeepSubsumptionFlag
@@ -649,7 +658,7 @@ tcValArg _ pos fun (EValArgQL {
; unless arg_influences_enclosing_call $ -- Don't repeat
qlUnify app_res_rho exp_arg_rho -- the qlUnify
- ; tc_args <- tcValArgs DoQL rn_fun inst_args
+ ; tc_args <- tcValArgs DoQL (rn_fun, snd tc_head) inst_args
; app_res_rho <- liftZonkM $ zonkTcType app_res_rho
; res_wrap <- checkResultTy rn_expr tc_head inst_args
app_res_rho (mkCheckExpType exp_arg_rho)
@@ -658,7 +667,7 @@ tcValArg _ pos fun (EValArgQL {
; traceTc "tcEValArgQL }" $
vcat [ text "app_res_rho:" <+> ppr app_res_rho ]
- ; return (EValArg { ea_loc_span = ctxt
+ ; return (EValArg { ea_loc_span = lspan
, ea_arg = L arg_loc (mkHsWrap wrap arg')
, ea_arg_ty = noExtField }) }
@@ -692,20 +701,20 @@ tcInstFun :: QLFlag
-- Generally speaking we pass in True; in Fig 5 of the paper
-- |-inst returns a rho-type
-> CtOrigin
- -> (HsExpr GhcTc, HsExpr GhcRn, SrcSpan)
+ -> (HsExpr GhcTc, HsExpr GhcRn, SrcSpan) -- ANI: TODO, move HsExpr GhcRn, SrcSpan to CtOrigin
-> TcSigmaType -> [HsExprArg 'TcpRn]
-> TcM ( [HsExprArg 'TcpInst]
, TcSigmaType ) -- Does not instantiate trailing invisible foralls
-- This crucial function implements the |-inst judgement in Fig 4, plus the
-- modification in Fig 5, of the QL paper:
-- "A quick look at impredicativity" (ICFP'20).
-tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
+tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
= do { traceTc "tcInstFun" (vcat [ text "origin" <+> ppr fun_orig
, text "tc_fun" <+> ppr tc_fun
, text "fun_sigma" <+> ppr fun_sigma
, text "args:" <+> ppr rn_args
, text "do_ql" <+> ppr do_ql
- , text "ctx" <+> ppr fun_ctxt])
+ , text "ctx" <+> ppr fun_lspan])
; setQLInstLevel do_ql $ -- See (TCAPP1) and (TCAPP2) in
-- Note [tcApp: typechecking applications]
go 1 [] fun_sigma rn_args }
@@ -782,7 +791,7 @@ tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
= do { (_inst_tvs, wrap, fun_rho) <-
-- addHeadCtxt: important for the class constraints
-- that may be emitted from instantiating fun_sigma
- setSrcSpan fun_ctxt $
+ setSrcSpan fun_lspan $
instantiateSigma fun_orig fun_conc_tvs tvs theta body2
-- See Note [Representation-polymorphism checking built-ins]
-- in GHC.Tc.Utils.Concrete.
@@ -877,7 +886,7 @@ tcInstFun do_ql inst_final fun_orig (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
(Just $ HsExprTcThing tc_fun)
(n_val_args, fun_sigma) fun_ty
- ; arg' <- quickLookArg do_ql pos ctxt rn_fun arg arg_ty
+ ; arg' <- quickLookArg do_ql pos ctxt (rn_fun, fun_lspan) arg arg_ty
; let acc' = arg' : addArgWrap wrap acc
; go (pos+1) acc' res_ty rest_args }
@@ -927,28 +936,48 @@ looks_like_type_arg EValArg{ ea_arg = L _ e } =
_ -> False
looks_like_type_arg _ = False
-addArgCtxt :: Int -> HsExpr GhcRn -> LHsExpr GhcRn
+addArgCtxt :: Int -> (HsExpr GhcRn, SrcSpan) -> LHsExpr GhcRn
-> TcM a -> TcM a
-- There are 2 cases:
--- 1. In the normal case, we add an informative context
--- "In the third argument of f, namely blah"
--- 2. If we are deep inside generated code (<=> `isGeneratedCode` is `True`)
--- "In the expression: arg"
--- If the arg is also a generated thing, i.e. `arg_loc` is `generatedSrcSpan`, we would print nothing.
+-- 1. In the normal case, we add an informative context (<=> `inGeneratedCode` is `False`)
+-- "In the third argument of f, namely blah"
+-- 2. If we are inside generated code (<=> `inGeneratedCode` is `True`)
+-- (i) If arg_loc is generated do nothing to to LclEnv/LclCtxt
+-- (ii) If arg_loc is Unhelpful UnhelpfulNoLocationInfo set `tcl_in_gen_code` to `True`
+-- (iii) if arg_loc is RealSrcLoc then update tcl_loc and add "In the expression: arg" to ErrCtxtStack
-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr
-- See Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do
-addArgCtxt arg_no fun (L arg_loc arg) thing_inside
+addArgCtxt arg_no (fun, fun_lspan) (L arg_loc arg) thing_inside
= do { in_generated_code <- inGeneratedCode
+ ; err_ctx <- getErrCtxt
+ ; env0 <- liftZonkM tcInitTidyEnv
+ ; err_ctx_msg <- mkErrCtxt env0 err_ctx
; traceTc "addArgCtxt" (vcat [ text "generated:" <+> ppr in_generated_code
- , text "arg: " <+> ppr arg
- , text "arg_loc" <+> ppr arg_loc])
- ; if in_generated_code
- then do setSrcSpanA arg_loc $
- addExprCtxt arg $ -- Auto-suppressed if arg_loc is generated
- thing_inside
- else do setSrcSpanA arg_loc $
- addErrCtxt (FunAppCtxt (FunAppCtxtExpr fun arg) arg_no) $
- thing_inside }
+ , text "arg: " <+> ppr (arg, arg_no)
+ , text "arg_loc:" <+> ppr arg_loc
+ , text "fun:" <+> ppr fun
+ , text "fun_lspan" <+> ppr fun_lspan
+ , text "err_ctx" <+> vcat (fmap (\ (x, y) ->
+ case x of
+ MkErrCtxt (ExpansionCodeCtxt{}) _ -> text "<EXPN>" <+> pprErrCtxtMsg y
+ _ -> text "<USER>" <+> pprErrCtxtMsg y)
+ (take 4 (zip err_ctx err_ctx_msg)))
+ ])
+ ; if not (isGeneratedSrcSpan fun_lspan)
+ then setSrcSpanA arg_loc $
+ addErrCtxt (FunAppCtxt (FunAppCtxtExpr fun arg) arg_no) $
+ thing_inside
+ else updCtxtForArg (L arg_loc arg) $
+ thing_inside
+ }
+ where
+ updCtxtForArg :: LHsExpr GhcRn -> TcRn a -> TcRn a
+ updCtxtForArg e@(L lspan _) thing_inside
+ = do setSrcSpan (locA lspan) $
+ addLExprCtxt e $ -- addLExpr is no op for non-user located exprs
+ thing_inside
+
+
{- *********************************************************************
* *
@@ -1724,24 +1753,26 @@ This turned out to be more subtle than I expected. Wrinkles:
-}
-quickLookArg :: QLFlag -> Int -> SrcSpan -> HsExpr GhcRn
+quickLookArg :: QLFlag -> Int
+ -> SrcSpan -- ^ location span of the whole application
+ -> (HsExpr GhcRn, SrcSpan) -- ^ Head of the application chain and its source span
-> LHsExpr GhcRn -- ^ Argument
-> Scaled TcSigmaTypeFRR -- ^ Type expected by the function
-> TcM (HsExprArg 'TcpInst)
-- See Note [Quick Look at value arguments]
-quickLookArg NoQL _ ctxt _ larg orig_arg_ty
- = skipQuickLook ctxt larg orig_arg_ty
-quickLookArg DoQL pos ctxt fun larg orig_arg_ty
+quickLookArg NoQL _ app_lspan _ larg orig_arg_ty
+ = skipQuickLook app_lspan larg orig_arg_ty
+quickLookArg DoQL pos app_lspan fun_and_lspan larg orig_arg_ty
= do { is_rho <- tcIsDeepRho (scaledThing orig_arg_ty)
; traceTc "qla" (ppr orig_arg_ty $$ ppr is_rho)
; if not is_rho
- then skipQuickLook ctxt larg orig_arg_ty
- else quickLookArg1 pos ctxt fun larg orig_arg_ty }
+ then skipQuickLook app_lspan larg orig_arg_ty
+ else quickLookArg1 pos app_lspan fun_and_lspan larg orig_arg_ty }
skipQuickLook :: SrcSpan -> LHsExpr GhcRn -> Scaled TcRhoType
-> TcM (HsExprArg 'TcpInst)
-skipQuickLook ctxt larg arg_ty
- = return (EValArg { ea_loc_span = ctxt
+skipQuickLook app_lspan larg arg_ty
+ = return (EValArg { ea_loc_span = app_lspan
, ea_arg = larg
, ea_arg_ty = arg_ty })
@@ -1779,14 +1810,14 @@ isGuardedTy ty
| Just {} <- tcSplitAppTy_maybe ty = True
| otherwise = False
-quickLookArg1 :: Int -> SrcSpan -> HsExpr GhcRn -> LHsExpr GhcRn
+quickLookArg1 :: Int -> SrcSpan -> (HsExpr GhcRn, SrcSpan) -> LHsExpr GhcRn
-> Scaled TcRhoType -- Deeply skolemised
-> TcM (HsExprArg 'TcpInst)
-- quickLookArg1 implements the "QL Argument" judgement in Fig 5 of the paper
-quickLookArg1 pos ctxt fun larg@(L _ arg) sc_arg_ty@(Scaled _ orig_arg_rho)
- = addArgCtxt pos fun larg $ -- Context needed for constraints
+quickLookArg1 pos app_lspan (fun, fun_lspan) larg@(L _ arg) sc_arg_ty@(Scaled _ orig_arg_rho)
+ = addArgCtxt pos (fun, fun_lspan) larg $ -- Context needed for constraints
-- generated by calls in arg
- do { ((rn_fun, fun_ctxt), rn_args) <- splitHsApps arg
+ do { ((rn_fun, fun_lspan), rn_args) <- splitHsApps arg
-- Step 1: get the type of the head of the argument
; (fun_ue, mb_fun_ty) <- tcCollectingUsage $ tcInferAppHead_maybe rn_fun
@@ -1802,15 +1833,15 @@ quickLookArg1 pos ctxt fun larg@(L _ arg) sc_arg_ty@(Scaled _ orig_arg_rho)
, text "args:" <+> ppr rn_args ]
; case mb_fun_ty of {
- Nothing -> skipQuickLook ctxt larg sc_arg_ty ; -- fun is too complicated
+ Nothing -> skipQuickLook app_lspan larg sc_arg_ty ; -- fun is too complicated
Just (tc_fun, fun_sigma) ->
-- step 2: use |-inst to instantiate the head applied to the arguments
- do { let tc_head = (tc_fun, fun_ctxt)
+ do { let tc_head = (tc_fun, fun_lspan)
; do_ql <- wantQuickLook rn_fun
; ((inst_args, app_res_rho), wanted)
<- captureConstraints $
- tcInstFun do_ql True (exprCtOrigin arg) (tc_fun, rn_fun, fun_ctxt) fun_sigma rn_args
+ tcInstFun do_ql True (exprCtOrigin arg) (tc_fun, rn_fun, fun_lspan) fun_sigma rn_args
-- We must capture type-class and equality constraints here, but
-- not equality constraints. See (QLA6) in Note [Quick Look at
-- value arguments]
@@ -1842,7 +1873,7 @@ quickLookArg1 pos ctxt fun larg@(L _ arg) sc_arg_ty@(Scaled _ orig_arg_rho)
; traceTc "quickLookArg done }" (ppr rn_fun)
- ; return (EValArgQL { eaql_loc_span = ctxt
+ ; return (EValArgQL { eaql_loc_span = app_lspan
, eaql_arg_ty = sc_arg_ty
, eaql_larg = larg
, eaql_tc_fun = tc_head
=====================================
compiler/GHC/Tc/Gen/Do.hs
=====================================
@@ -97,7 +97,7 @@ expand_do_stmts doFlavour (stmt@(L loc (LetStmt _ bs)) : lstmts) =
-- ------------------------------------------------
-- let x = e ; stmts ~~> let x = e in stmts'
do expand_stmts_expr <- expand_do_stmts doFlavour lstmts
- let expansion = genHsLet bs (genPopErrCtxtExpr expand_stmts_expr)
+ let expansion = genHsLet bs expand_stmts_expr
return $ L loc (mkExpandedStmt stmt doFlavour expansion)
expand_do_stmts doFlavour (stmt@(L loc (BindStmt xbsrn pat e)): lstmts)
@@ -110,15 +110,15 @@ expand_do_stmts doFlavour (stmt@(L loc (BindStmt xbsrn pat e)): lstmts)
-- -------------------------------------------------------
-- pat <- e ; stmts ~~> (>>=) e f
= do expand_stmts_expr <- expand_do_stmts doFlavour lstmts
- failable_expr <- mk_failable_expr doFlavour pat (genPopErrCtxtExpr expand_stmts_expr) fail_op
+ failable_expr <- mk_failable_expr doFlavour pat expand_stmts_expr fail_op
let expansion = genHsExpApps bind_op -- (>>=)
- [ genPopErrCtxtExpr e
+ [ e
, failable_expr ]
return $ L loc (mkExpandedStmt stmt doFlavour expansion)
| otherwise
= pprPanic "expand_do_stmts: The impossible happened, missing bind operator from renamer" (text "stmt" <+> ppr stmt)
-expand_do_stmts doFlavour (stmt@(L loc (BodyStmt _ e (SyntaxExprRn then_op) _)) : lstmts) =
+expand_do_stmts doFlavour (stmt@(L loc (BodyStmt _ (L e_lspan e) (SyntaxExprRn then_op) _)) : lstmts) =
-- See Note [BodyStmt] in Language.Haskell.Syntax.Expr
-- See Note [Expanding HsDo with XXExprGhcRn] Equation (1) below
-- stmts ~~> stmts'
@@ -126,8 +126,8 @@ expand_do_stmts doFlavour (stmt@(L loc (BodyStmt _ e (SyntaxExprRn then_op) _))
-- e ; stmts ~~> (>>) e stmts'
do expand_stmts_expr <- expand_do_stmts doFlavour lstmts
let expansion = genHsExpApps then_op -- (>>)
- [ genPopErrCtxtExpr e
- , genPopErrCtxtExpr $ expand_stmts_expr ]
+ [ L e_lspan (mkExpandedStmt stmt doFlavour e)
+ , expand_stmts_expr ]
return $ L loc (mkExpandedStmt stmt doFlavour expansion)
expand_do_stmts doFlavour
@@ -484,12 +484,5 @@ It stores the original statement (with location) and the expanded expression
-}
--- | Wrap a located expression with a `PopErrCtxt`
-mkPopErrCtxtExpr :: HsExpr GhcRn -> HsExpr GhcRn
-mkPopErrCtxtExpr a = XExpr (PopErrCtxt a)
-
-genPopErrCtxtExpr :: LHsExpr GhcRn -> LHsExpr GhcRn
-genPopErrCtxtExpr (L loc a) = L loc (mkPopErrCtxtExpr a)
-
mkExpandedPatRn :: Pat GhcRn -> HsExpr GhcRn -> HsExpr GhcRn
mkExpandedPatRn pat e = XExpr (ExpandedThingRn (OrigPat pat) e)
=====================================
compiler/GHC/Tc/Gen/Expr.hs
=====================================
@@ -122,7 +122,7 @@ tcPolyLExpr, tcPolyLExprNC :: LHsExpr GhcRn -> ExpSigmaType
tcPolyLExpr (L loc expr) res_ty
= setSrcSpanA loc $ -- Set location /first/; see GHC.Tc.Utils.Monad
- addExprCtxt expr $ -- Note [Error contexts in generated code]
+ addLExprCtxt (L loc expr) $ -- Note [Error contexts in generated code]
do { expr' <- tcPolyExpr expr res_ty
; return (L loc expr') }
@@ -241,7 +241,7 @@ tcInferRhoNC = tcInferExprNC IIF_DeepRho
tcInferExpr, tcInferExprNC :: InferInstFlag -> LHsExpr GhcRn -> TcM (LHsExpr GhcTc, TcType)
tcInferExpr iif (L loc expr)
= setSrcSpanA loc $ -- Set location /first/; see GHC.Tc.Utils.Monad
- addExprCtxt expr $ -- Note [Error contexts in generated code]
+ addLExprCtxt (L loc expr) $ -- Note [Error contexts in generated code]
do { (expr', rho) <- runInfer iif IFRR_Any (tcExpr expr)
; return (L loc expr', rho) }
@@ -268,7 +268,7 @@ tcMonoLExpr, tcMonoLExprNC
tcMonoLExpr (L loc expr) res_ty
= setSrcSpanA loc $ -- Set location /first/; see GHC.Tc.Utils.Monad
- addExprCtxt expr $ -- Note [Error contexts in generated code]
+ addLExprCtxt (L loc expr) $ -- Note [Error contexts in generated code]
do { expr' <- tcExpr expr res_ty
; return (L loc expr') }
@@ -660,10 +660,10 @@ tcExpr expr@(RecordUpd { rupd_expr = record_expr
res_ty
= assert (notNull rbnds) $
do { -- Expand the record update. See Note [Record Updates].
+
; (ds_expr, ds_res_ty, err_msg)
<- expandRecordUpd record_expr possible_parents rbnds res_ty
- ; addErrCtxt err_msg $
- setInGeneratedCode (OrigExpr expr) $
+ ; addExpansionErrCtxt (OrigExpr expr) err_msg $
do { -- Typecheck the expanded expression.
expr' <- tcExpr ds_expr (Check ds_res_ty)
-- NB: it's important to use ds_res_ty and not res_ty here.
@@ -718,7 +718,7 @@ tcExpr (HsProjection _ _) _ = panic "GHC.Tc.Gen.Expr: tcExpr: HsProjection: Not
-- Here we get rid of it and add the finalizers to the global environment.
-- See Note [Delaying modFinalizers in untyped splices] in GHC.Rename.Splice.
tcExpr (HsTypedSplice ext splice) res_ty = tcTypedSplice ext splice res_ty
-tcExpr e@(HsTypedBracket _ext body) res_ty = tcTypedBracket e body res_ty
+tcExpr e@(HsTypedBracket _ext body) res_ty = tcTypedBracket e body res_ty
tcExpr e@(HsUntypedBracket ps body) res_ty = tcUntypedBracket e body ps res_ty
tcExpr (HsUntypedSplice splice _) res_ty
@@ -753,18 +753,9 @@ tcExpr (SectionR {}) ty = pprPanic "tcExpr:SectionR" (ppr ty)
-}
tcXExpr :: XXExprGhcRn -> ExpRhoType -> TcM (HsExpr GhcTc)
-
-tcXExpr (PopErrCtxt e) res_ty
- = do popErrCtxt $ -- See Part 3 of Note [Expanding HsDo with XXExprGhcRn] in `GHC.Tc.Gen.Do`
- addExprCtxt e $
- tcExpr e res_ty
-
tcXExpr (ExpandedThingRn o e) res_ty
- = setInGeneratedCode o $
- -- e is the expanded expression of o, so we need to set the error ctxt to generated
- -- see Note [Error Context Stack] in `GHC.Tc.Type.LclEnv`
- mkExpandedTc o <$> -- necessary for hpc ticks
- tcExpr e res_ty
+ = mkExpandedTc o <$> -- necessary for hpc ticks
+ tcExpr e res_ty
-- For record selection, same as HsVar case
tcXExpr xe res_ty = tcApp (XExpr xe) res_ty
@@ -1480,7 +1471,7 @@ expandRecordUpd record_expr possible_parents rbnds res_ty
ds_expr = HsLet noExtField let_binds (wrapGenSpan case_expr)
case_expr :: HsExpr GhcRn
- case_expr = HsCase RecUpd record_expr
+ case_expr = HsCase RecUpd (wrapGenSpan (unLoc record_expr))
$ mkMatchGroup (Generated OtherExpansion DoPmc) (wrapGenSpan matches)
matches :: [LMatch GhcRn (LHsExpr GhcRn)]
matches = map make_pat (NE.toList relevant_cons)
=====================================
compiler/GHC/Tc/Gen/Head.hs
=====================================
@@ -26,7 +26,7 @@ module GHC.Tc.Gen.Head
, nonBidirectionalErr
, pprArgInst
- , addExprCtxt, addFunResCtxt ) where
+ , addExprCtxt, addLExprCtxt, addFunResCtxt ) where
import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcExpr, tcCheckPolyExprNC, tcPolyLExprSig )
import {-# SOURCE #-} GHC.Tc.Gen.Splice( getUntypedSpliceBody )
@@ -49,6 +49,7 @@ import GHC.Tc.Solver ( InferMode(..), simplifyInfer )
import GHC.Tc.Utils.Env
import GHC.Tc.Utils.TcMType
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt ( srcCodeOriginErrCtxMsg )
import GHC.Tc.Types.Constraint( WantedConstraints )
import GHC.Tc.Utils.TcType as TcType
import GHC.Tc.Types.Evidence
@@ -174,7 +175,7 @@ data HsExprArg (p :: TcPass) where -- See Note [HsExprArg]
, eaql_larg :: LHsExpr GhcRn -- Original application, for
-- location and error msgs
, eaql_rn_fun :: HsExpr GhcRn -- Head of the argument if it is an application
- , eaql_tc_fun :: (HsExpr GhcTc, SrcSpan) -- Typechecked head
+ , eaql_tc_fun :: (HsExpr GhcTc, SrcSpan) -- Typechecked head and its location span
, eaql_fun_ue :: UsageEnv -- Usage environment of the typechecked head (QLA5)
, eaql_args :: [HsExprArg 'TcpInst] -- Args: instantiated, not typechecked
, eaql_wanted :: WantedConstraints
@@ -217,7 +218,7 @@ type family XPass (p :: TcPass) where
mkEValArg :: SrcSpan -> LHsExpr GhcRn -> HsExprArg 'TcpRn
mkEValArg src_loc e = EValArg { ea_arg = e, ea_loc_span = src_loc
- , ea_arg_ty = noExtField }
+ , ea_arg_ty = noExtField }
mkETypeArg :: SrcSpan -> LHsWcType GhcRn -> HsExprArg 'TcpRn
mkETypeArg src_loc hs_ty =
@@ -244,18 +245,18 @@ splitHsApps e = go e noSrcSpan []
go :: HsExpr GhcRn -> SrcSpan -> [HsExprArg 'TcpRn]
-> TcM ((HsExpr GhcRn, SrcSpan), [HsExprArg 'TcpRn])
-- Modify the SrcSpan as we walk inwards, so it describes the next argument
- go (HsPar _ (L l fun)) sloc args = go fun (locA l) (EWrap (EPar sloc) : args)
- go (HsPragE _ p (L l fun)) sloc args = go fun (locA l) (EPrag sloc p : args)
- go (HsAppType _ (L l fun) ty) sloc args = go fun (locA l) (mkETypeArg sloc ty : args)
- go (HsApp _ (L l fun) arg) sloc args = go fun (locA l) (mkEValArg sloc arg : args)
+ go (HsPar _ (L l fun)) lspan args = go fun (locA l) (EWrap (EPar lspan) : args)
+ go (HsPragE _ p (L l fun)) lspan args = go fun (locA l) (EPrag lspan p : args)
+ go (HsAppType _ (L l fun) ty) lspan args = go fun (locA l) (mkETypeArg lspan ty : args)
+ go (HsApp _ (L l fun) arg) lspan args = go fun (locA l) (mkEValArg lspan arg : args)
-- See Note [Looking through Template Haskell splices in splitHsApps]
go e@(HsUntypedSplice splice_res splice) _ args
= do { fun <- getUntypedSpliceBody splice_res
- ; go fun sloc' (EWrap (EExpand e) : args) }
+ ; go fun lspan' (EWrap (EExpand e) : args) }
where
- sloc' :: SrcSpan
- sloc' = case splice of
+ lspan' :: SrcSpan
+ lspan' = case splice of
HsUntypedSpliceExpr _ (L l _) -> locA l -- l :: SrcAnn AnnListItem
HsQuasiQuote _ _ (L l _) -> locA l -- l :: SrcAnn NoEpAnns
(XUntypedSplice (HsImplicitLiftSplice _ _ _ (L l _))) -> locA l
@@ -269,11 +270,10 @@ splitHsApps e = go e noSrcSpan []
-- and its hard to say exactly what that is
: EWrap (EExpand e)
: args )
- go (XExpr (PopErrCtxt fun)) sloc args = go fun sloc args
-- look through PopErrCtxt (cf. T17594f) we do not want to lose the opportunity of calling tcEValArgQL
-- unlike HsPar, it is okay to forget about the PopErrCtxts as it does not persist over in GhcTc land
- go e sloc args = pure ((e, sloc), args)
+ go e lspan args = pure ((e, lspan), args)
-- | Rebuild an application: takes a type-checked application head
@@ -456,8 +456,8 @@ tcInferAppHead :: (HsExpr GhcRn, SrcSpan)
-- cases are dealt with by splitHsApps.
--
-- See Note [tcApp: typechecking applications] in GHC.Tc.Gen.App
-tcInferAppHead (fun,fun_loc)
- = setSrcSpan fun_loc $
+tcInferAppHead (fun,fun_lspan)
+ = setSrcSpan fun_lspan $
do { mb_tc_fun <- tcInferAppHead_maybe fun
; case mb_tc_fun of
Just (fun', fun_sigma) -> return (fun', fun_sigma)
@@ -471,9 +471,9 @@ tcInferAppHead_maybe fun =
case fun of
HsVar _ nm -> Just <$> tcInferId nm
XExpr (HsRecSelRn f) -> Just <$> tcInferRecSelId f
- XExpr (ExpandedThingRn o e) -> Just <$> (setInGeneratedCode o $ -- We do not want to instantiate c.f. T19167
- tcExprSigma False e)
- XExpr (PopErrCtxt e) -> tcInferAppHead_maybe e
+ XExpr (ExpandedThingRn o e) -> Just <$> (addExpansionErrCtxt o (srcCodeOriginErrCtxMsg o) $
+ -- We do not want to instantiate c.f. T19167
+ tcExprSigma False e)
ExprWithTySig _ e hs_ty -> Just <$> tcExprWithSig e hs_ty
HsOverLit _ lit -> Just <$> tcInferOverLit lit
_ -> return Nothing
@@ -1109,5 +1109,17 @@ addExprCtxt e thing_inside
-- f x = _
-- when we don't want to say "In the expression: _",
-- because it is mentioned in the error message itself
- XExpr (PopErrCtxt _) -> thing_inside -- popErrCtxt shouldn't push ctxt. see typechecking let stmts
+ HsPar{} -> thing_inside
+ -- We don't want to say 'In the expression (e)',
+ -- we just want to say 'In the expression, 'e'
+ -- which will be handeled by the recursive call in thing_inside
+ XExpr (ExpandedThingRn o _) -> addExpansionErrCtxt o (srcCodeOriginErrCtxMsg o) thing_inside
_ -> addErrCtxt (ExprCtxt e) thing_inside -- no op in generated code
+
+
+addLExprCtxt :: LHsExpr GhcRn -> TcRn a -> TcRn a
+addLExprCtxt (L lspan e) thing_inside
+ | (RealSrcSpan{}) <- locA lspan
+ = addExprCtxt e thing_inside
+ | otherwise
+ = thing_inside
=====================================
compiler/GHC/Tc/Gen/Match.hs
=====================================
@@ -57,6 +57,7 @@ import GHC.Tc.Gen.Bind
import GHC.Tc.Utils.Concrete ( hasFixedRuntimeRep_syntactic )
import GHC.Tc.Utils.Unify
import GHC.Tc.Types.Origin
+import GHC.Tc.Types.ErrCtxt ( srcCodeOriginErrCtxMsg )
import GHC.Tc.Types.Evidence
import GHC.Rename.Env ( irrefutableConLikeTc )
@@ -330,6 +331,7 @@ tcMatch tc_body pat_tys rhs_ty match
add_match_ctxt thing_inside = case ctxt of
LamAlt LamSingle -> thing_inside
StmtCtxt (HsDoStmt{}) -> thing_inside -- this is an expanded do stmt
+ RecUpd -> thing_inside -- record update is Expanded out so ignore it
_ -> addErrCtxt (MatchInCtxt match) thing_inside
-------------
@@ -404,9 +406,9 @@ tcDoStmts doExpr@(DoExpr _) ss@(L l stmts) res_ty
; return (HsDo res_ty doExpr (L l stmts')) }
else do { expanded_expr <- expandDoStmts doExpr stmts -- Do expansion on the fly
; let orig = HsDo noExtField doExpr ss
- ; setInGeneratedCode (OrigExpr orig) $ do
- { e' <- tcMonoLExpr expanded_expr res_ty
- ; return (mkExpandedExprTc orig (unLoc e'))}
+ ; addExpansionErrCtxt (OrigExpr orig) (srcCodeOriginErrCtxMsg (OrigExpr orig)) $
+ do { e' <- tcMonoLExpr expanded_expr res_ty
+ ; return (mkExpandedExprTc orig (unLoc e'))}
}
}
=====================================
compiler/GHC/Tc/Instance/Class.hs
=====================================
@@ -61,7 +61,6 @@ import GHC.Unit.Module.Warnings
import GHC.Hs
-import Language.Haskell.Syntax.Basic (FieldLabelString(..))
import GHC.Tc.Errors.Types
import Data.Maybe
=====================================
compiler/GHC/Tc/Types/ErrCtxt.hs
=====================================
@@ -4,7 +4,7 @@
{-# LANGUAGE UndecidableInstances #-}
module GHC.Tc.Types.ErrCtxt
- ( ErrCtxt, ErrCtxtMsg(..)
+ ( ErrCtxt (..), ErrCtxtMsg(..), ErrCtxtMsgM, CodeSrcFlag (..), srcCodeOriginErrCtxMsg
, UserSigType(..), FunAppCtxtFunArg(..)
, TyConInstFlavour(..)
)
@@ -23,7 +23,7 @@ import GHC.Tc.Zonk.Monad ( ZonkM )
import GHC.Types.Basic ( TyConFlavour )
import GHC.Types.Name ( Name )
-import GHC.Types.SrcLoc ( SrcSpan )
+import GHC.Types.SrcLoc ( SrcSpan, unLoc )
import GHC.Types.Var ( Id, TyCoVar )
import GHC.Types.Var.Env ( TidyEnv )
@@ -48,15 +48,22 @@ import qualified Data.List.NonEmpty as NE
--------------------------------------------------------------------------------
+type ErrCtxtMsgM = TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)
+
-- | Additional context to include in an error message, e.g.
-- "In the type signature ...", "In the ambiguity check for ...", etc.
-type ErrCtxt = (Bool, TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg))
- -- Monadic so that we have a chance
- -- to deal with bound type variables just before error
- -- message construction
+data ErrCtxt = MkErrCtxt CodeSrcFlag ErrCtxtMsgM
+ -- Monadic so that we have a chance
+ -- to deal with bound type variables just before error
+ -- message construction
+
+ -- Bool: True <=> this is a landmark context; do not
+ -- discard it when trimming for display
- -- Bool: True <=> this is a landmark context; do not
- -- discard it when trimming for display
+data CodeSrcFlag = VanillaUserSrcCode
+ | LandmarkUserSrcCode
+ | ExpansionCodeCtxt SrcCodeOrigin
+ -- INVARIANT: SHOULD NEVER APPEAR IN A ExpansionCodeCtxt in CodeSrcFlag ErrCtxt on stack
--------------------------------------------------------------------------------
-- Error message contexts
@@ -221,3 +228,10 @@ data ErrCtxtMsg
| MergeSignaturesCtxt !UnitState !ModuleName ![InstantiatedModule]
-- | While checking that a module implements a Backpack signature.
| CheckImplementsCtxt !UnitState !Module !InstantiatedModule
+
+
+srcCodeOriginErrCtxMsg :: SrcCodeOrigin -> ErrCtxtMsg
+srcCodeOriginErrCtxMsg (OrigExpr e) = ExprCtxt e
+srcCodeOriginErrCtxMsg (OrigStmt s f) = StmtErrCtxt (HsDoStmt f) (unLoc s)
+srcCodeOriginErrCtxMsg (OrigPat p) = PatCtxt p
+srcCodeOriginErrCtxMsg (PopErrCtxt) = error "Shouldn't happen srcCodeOriginErr"
=====================================
compiler/GHC/Tc/Types/LclEnv.hs
=====================================
@@ -28,7 +28,7 @@ module GHC.Tc.Types.LclEnv (
, addLclEnvErrCtxt
- , ErrCtxtStack (..)
+ , ErrCtxtStack
, ArrowCtxt(..)
, ThBindEnv
, TcTypeEnv
@@ -36,7 +36,7 @@ module GHC.Tc.Types.LclEnv (
import GHC.Prelude
-import GHC.Hs ( SrcCodeOrigin )
+import GHC.Hs ( SrcCodeOrigin (..) )
import GHC.Tc.Utils.TcType ( TcLevel )
import GHC.Tc.Errors.Types ( TcRnMessage )
@@ -92,15 +92,19 @@ data TcLclEnv -- Changes as we move inside an expression
}
{-
-Note [Error Context Stack]
-~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Note [ErrCtxtStack Manipulation]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The ErrCtxtStack is a list of ErrCtxt
+ANI: TODO. explain how this works. When is the top of the stack overwritten? When an error ctxt pushed on top
+
This data structure keeps track of two things:
1. Are we type checking a compiler generated/non-user written code.
2. The trail of the error messages that have been added in route to the current expression
* When the `ErrCtxtStack` is a `UserCodeCtxt`,
- the current expression being typechecked is user written
-* When the `ErrorCtxtStack` is a `GeneratedCodeCtxt`
+* When the `ErrorCtxtStack` is a `ExpansionCodeCtxt`
- the current expression being typechecked is compiler generated;
- the original, possibly user written, source code thing is stored in `src_code_origin` field.
- the `src_code_origin` is what will be blamed in the error message
@@ -109,39 +113,22 @@ This data structure keeps track of two things:
-- See Note [Error Context Stack]
-data ErrCtxtStack
- = UserCodeCtxt { lcl_err_ctxt :: [ErrCtxt] } -- ^ Trail of error messages
- | GeneratedCodeCtxt { src_code_origin :: SrcCodeOrigin -- ^ Original, user written code
- , lcl_err_ctxt :: [ErrCtxt] } -- ^ Trail of error messages
-
--- | Are we in a generated context?
-isGeneratedCodeCtxt :: ErrCtxtStack -> Bool
-isGeneratedCodeCtxt UserCodeCtxt{} = False
-isGeneratedCodeCtxt _ = True
+type ErrCtxtStack = [ErrCtxt]
-- | Get the original source code
get_src_code_origin :: ErrCtxtStack -> Maybe SrcCodeOrigin
-get_src_code_origin (UserCodeCtxt{}) = Nothing
- -- we are in user code, so blame the expression in hand
-get_src_code_origin es = Just $ src_code_origin es
- -- we are in generated code, so extract the original expression
-
--- | Modify the error context stack
--- N.B. If we are in a generated context, any updates to the context stack are ignored.
--- We want to blame the errors that appear in a generated expression
--- to the original, user written code
-modify_err_ctxt_stack :: ([ErrCtxt] -> [ErrCtxt]) -> ErrCtxtStack -> ErrCtxtStack
-modify_err_ctxt_stack f (UserCodeCtxt e) = UserCodeCtxt (f e)
-modify_err_ctxt_stack _ c = c -- any updates on the err context in a generated context should be ignored
-
+get_src_code_origin (MkErrCtxt (ExpansionCodeCtxt origSrcCode) _ : _) = Just origSrcCode
+ -- we are in generated code, due to the expansion of the original syntax origSrcCode
+get_src_code_origin _ = Nothing
+ -- we are in user code, so blame the expression in hand
data TcLclCtxt
= TcLclCtxt {
- tcl_loc :: RealSrcSpan, -- Source span
- tcl_ctxt :: ErrCtxtStack, -- See Note [Error Context Stack]
- tcl_tclvl :: TcLevel,
- tcl_bndrs :: TcBinderStack, -- Used for reporting relevant bindings,
- -- and for tidying type
+ tcl_loc :: RealSrcSpan, -- Source span
+ tcl_err_ctxt :: ErrCtxtStack, -- See Note [Error Context Stack]
+ tcl_tclvl :: TcLevel,
+ tcl_bndrs :: TcBinderStack, -- Used for reporting relevant bindings,
+ -- and for tidying type
tcl_rdr :: LocalRdrEnv, -- Local name envt
-- Maintained during renaming, of course, but also during
@@ -203,28 +190,40 @@ getLclEnvLoc :: TcLclEnv -> RealSrcSpan
getLclEnvLoc = tcl_loc . tcl_lcl_ctxt
getLclEnvErrCtxt :: TcLclEnv -> [ErrCtxt]
-getLclEnvErrCtxt = lcl_err_ctxt . tcl_ctxt . tcl_lcl_ctxt
+getLclEnvErrCtxt = tcl_err_ctxt . tcl_lcl_ctxt
-setLclEnvErrCtxt :: [ErrCtxt] -> TcLclEnv -> TcLclEnv
-setLclEnvErrCtxt ctxt = modifyLclCtxt (\env -> env { tcl_ctxt = modify_err_ctxt_stack (\ _ -> ctxt) (tcl_ctxt env) })
+setLclEnvErrCtxt :: ErrCtxtStack -> TcLclEnv -> TcLclEnv
+setLclEnvErrCtxt ctxt = modifyLclCtxt (\env -> env { tcl_err_ctxt = ctxt })
addLclEnvErrCtxt :: ErrCtxt -> TcLclEnv -> TcLclEnv
-addLclEnvErrCtxt ec = modifyLclCtxt (\env -> env { tcl_ctxt = modify_err_ctxt_stack (\ctxt -> ec : ctxt) (tcl_ctxt env) })
+addLclEnvErrCtxt ec = setLclEnvSrcCodeOrigin ec
getLclEnvSrcCodeOrigin :: TcLclEnv -> Maybe SrcCodeOrigin
-getLclEnvSrcCodeOrigin = get_src_code_origin . tcl_ctxt . tcl_lcl_ctxt
-
-setLclEnvSrcCodeOrigin :: SrcCodeOrigin -> TcLclEnv -> TcLclEnv
-setLclEnvSrcCodeOrigin o = modifyLclCtxt (setLclCtxtSrcCodeOrigin o)
-
-setLclCtxtSrcCodeOrigin :: SrcCodeOrigin -> TcLclCtxt -> TcLclCtxt
-setLclCtxtSrcCodeOrigin o ctxt = ctxt { tcl_ctxt = GeneratedCodeCtxt o (lcl_err_ctxt $ tcl_ctxt ctxt) }
+getLclEnvSrcCodeOrigin = get_src_code_origin . tcl_err_ctxt . tcl_lcl_ctxt
+
+setLclEnvSrcCodeOrigin :: ErrCtxt -> TcLclEnv -> TcLclEnv
+setLclEnvSrcCodeOrigin ec = modifyLclCtxt (setLclCtxtSrcCodeOrigin ec)
+
+-- See Note [ErrCtxt Stack Manipulation]
+setLclCtxtSrcCodeOrigin :: ErrCtxt -> TcLclCtxt -> TcLclCtxt
+setLclCtxtSrcCodeOrigin ec lclCtxt
+ | MkErrCtxt (ExpansionCodeCtxt PopErrCtxt) _ <- ec
+ = lclCtxt { tcl_err_ctxt = tail (tcl_err_ctxt lclCtxt) }
+ | MkErrCtxt (ExpansionCodeCtxt _) _ : ecs <- tcl_err_ctxt lclCtxt
+ , MkErrCtxt (ExpansionCodeCtxt _) _ <- ec
+ = lclCtxt { tcl_err_ctxt = ec : ecs }
+ | otherwise
+ = lclCtxt { tcl_err_ctxt = ec : tcl_err_ctxt lclCtxt }
lclCtxtInGeneratedCode :: TcLclCtxt -> Bool
-lclCtxtInGeneratedCode = isGeneratedCodeCtxt . tcl_ctxt
+lclCtxtInGeneratedCode lclCtxt
+ | (MkErrCtxt (ExpansionCodeCtxt _) _ : _) <- tcl_err_ctxt lclCtxt
+ = True
+ | otherwise
+ = False
lclEnvInGeneratedCode :: TcLclEnv -> Bool
-lclEnvInGeneratedCode = lclCtxtInGeneratedCode . tcl_lcl_ctxt
+lclEnvInGeneratedCode = lclCtxtInGeneratedCode . tcl_lcl_ctxt
getLclEnvBinderStack :: TcLclEnv -> TcBinderStack
getLclEnvBinderStack = tcl_bndrs . tcl_lcl_ctxt
=====================================
compiler/GHC/Tc/Types/Origin.hs
=====================================
@@ -837,8 +837,7 @@ exprCtOrigin e@(HsProjection _ _) = ExpansionOrigin (OrigExpr e)
exprCtOrigin e@(RecordUpd{}) = ExpansionOrigin (OrigExpr e)
exprCtOrigin e@(HsGetField{}) = ExpansionOrigin (OrigExpr e)
exprCtOrigin (XExpr (ExpandedThingRn o _)) = ExpansionOrigin o
-exprCtOrigin (XExpr (PopErrCtxt e)) = exprCtOrigin e
-exprCtOrigin (XExpr (HsRecSelRn f)) = OccurrenceOfRecSel (foExt f)
+exprCtOrigin (XExpr (HsRecSelRn f)) = OccurrenceOfRecSel $ L (getLoc $ foLabel f) (foExt f)
srcCodeOriginCtOrigin :: HsExpr GhcRn -> Maybe SrcCodeOrigin -> CtOrigin
srcCodeOriginCtOrigin e Nothing = exprCtOrigin e
@@ -889,6 +888,7 @@ pprCtOrigin (ExpansionOrigin o)
OrigExpr (ExplicitList{}) -> text "an overloaded list"
OrigExpr (HsIf{}) -> text "an if-then-else expression"
OrigExpr e -> text "the expression" <+> (ppr e)
+ PopErrCtxt -> text "Shouldn't Happen PopErrCtxt"
pprCtOrigin (GivenSCOrigin sk d blk)
= vcat [ ctoHerald <+> pprSkolInfo sk
@@ -1121,6 +1121,7 @@ ppr_br (ExpansionOrigin (OrigExpr (HsIf{}))) = text "an if-then-else expression"
ppr_br (ExpansionOrigin (OrigExpr e)) = text "an expression" <+> ppr e
ppr_br (ExpansionOrigin (OrigStmt{})) = text "a do statement"
ppr_br (ExpansionOrigin (OrigPat{})) = text "a do statement"
+ppr_br (ExpansionOrigin PopErrCtxt) = text "SHOULDN'T HAPPEN POPERRORCTXT"
ppr_br (ExpectedTySyntax o _) = ppr_br o
ppr_br (ExpectedFunTySyntaxOp{}) = text "a rebindable syntax operator"
ppr_br (ExpectedFunTyViewPat{}) = text "a view pattern"
=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -63,7 +63,7 @@ module GHC.Tc.Utils.Monad(
-- * Error management
getSrcCodeOrigin,
getSrcSpanM, setSrcSpan, setSrcSpanA, addLocM,
- inGeneratedCode, setInGeneratedCode,
+ inGeneratedCode, -- setInGeneratedCode,
wrapLocM, wrapLocFstM, wrapLocFstMA, wrapLocSndM, wrapLocSndMA, wrapLocM_,
wrapLocMA_,wrapLocMA,
getErrsVar, setErrsVar,
@@ -88,6 +88,7 @@ module GHC.Tc.Utils.Monad(
-- * Context management for the type checker
getErrCtxt, setErrCtxt, addErrCtxt, addErrCtxtM, addLandmarkErrCtxt,
+ addExpansionErrCtxt, addExpansionErrCtxtM,
addLandmarkErrCtxtM, popErrCtxt, getCtLocM, setCtLocM, mkCtLocEnv,
-- * Diagnostic message generation (type checker)
@@ -172,6 +173,7 @@ import GHC.Tc.Types -- Re-export all
import GHC.Tc.Types.Constraint
import GHC.Tc.Types.CtLoc
import GHC.Tc.Types.Evidence
+import GHC.Tc.Types.ErrCtxt
import GHC.Tc.Types.LclEnv
import GHC.Tc.Types.Origin
import GHC.Tc.Types.TcRef
@@ -418,7 +420,7 @@ initTcWithGbl hsc_env gbl_env loc do_this
tcl_lcl_ctxt = TcLclCtxt {
tcl_loc = loc,
-- tcl_loc should be over-ridden very soon!
- tcl_ctxt = UserCodeCtxt [],
+ tcl_err_ctxt = [],
tcl_rdr = emptyLocalRdrEnv,
tcl_th_ctxt = topLevel,
tcl_th_bndrs = emptyNameEnv,
@@ -1077,23 +1079,27 @@ inGeneratedCode = lclEnvInGeneratedCode <$> getLclEnv
setSrcSpan :: SrcSpan -> TcRn a -> TcRn a
-- See Note [Error contexts in generated code]
setSrcSpan (RealSrcSpan loc _) thing_inside
- = updLclCtxt (\env -> env { tcl_loc = loc
- , tcl_ctxt = UserCodeCtxt (lcl_err_ctxt $ tcl_ctxt env)})
- thing_inside
+ = updLclCtxt (\env -> env { tcl_loc = loc }) thing_inside
setSrcSpan (UnhelpfulSpan _) thing_inside
= thing_inside
getSrcCodeOrigin :: TcRn (Maybe SrcCodeOrigin)
-getSrcCodeOrigin = getLclEnvSrcCodeOrigin <$> getLclEnv
+getSrcCodeOrigin =
+ do inGenCode <- inGeneratedCode
+ if inGenCode
+ then getLclEnvSrcCodeOrigin <$> getLclEnv
+ else return Nothing
+
-- | Mark the inner computation as being done inside generated code.
--
-- See Note [Error contexts in generated code]
-- See Note [Error Context Stack]
-setInGeneratedCode :: SrcCodeOrigin -> TcRn a -> TcRn a
-setInGeneratedCode sco thing_inside =
- updLclCtxt (setLclCtxtSrcCodeOrigin sco) thing_inside
+-- setInGeneratedCode :: SrcCodeOrigin -> TcRn a -> TcRn a
+-- setInGeneratedCode sco thing_inside =
+-- -- updLclCtxt setLclCtxtInGenCode $
+-- updLclCtxt (setLclCtxtSrcCodeOrigin sco) thing_inside
setSrcSpanA :: EpAnn ann -> TcRn a -> TcRn a
setSrcSpanA l = setSrcSpan (locA l)
@@ -1341,12 +1347,20 @@ addErrCtxt :: ErrCtxtMsg -> TcM a -> TcM a
{-# INLINE addErrCtxt #-} -- Note [Inlining addErrCtxt]
addErrCtxt msg = addErrCtxtM (\env -> return (env, msg))
+addExpansionErrCtxt :: SrcCodeOrigin -> ErrCtxtMsg -> TcM a -> TcM a
+{-# INLINE addExpansionErrCtxt #-} -- Note [Inlining addErrCtxt]
+addExpansionErrCtxt o msg = addExpansionErrCtxtM o (\env -> return (env, msg))
+
-- | Add a message to the error context. This message may do tidying.
-- NB. No op in generated code
-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr
addErrCtxtM :: (TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)) -> TcM a -> TcM a
{-# INLINE addErrCtxtM #-} -- Note [Inlining addErrCtxt]
-addErrCtxtM ctxt = pushCtxt (False, ctxt)
+addErrCtxtM ctxt = pushCtxt (MkErrCtxt VanillaUserSrcCode ctxt)
+
+addExpansionErrCtxtM :: SrcCodeOrigin -> (TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)) -> TcM a -> TcM a
+{-# INLINE addExpansionErrCtxtM #-} -- Note [Inlining addErrCtxt]
+addExpansionErrCtxtM o ctxt = pushCtxt (MkErrCtxt (ExpansionCodeCtxt o) ctxt)
-- | Add a fixed landmark message to the error context. A landmark
-- message is always sure to be reported, even if there is a lot of
@@ -1360,7 +1374,7 @@ addLandmarkErrCtxt msg = addLandmarkErrCtxtM (\env -> return (env, msg))
-- and tidying.
addLandmarkErrCtxtM :: (TidyEnv -> ZonkM (TidyEnv, ErrCtxtMsg)) -> TcM a -> TcM a
{-# INLINE addLandmarkErrCtxtM #-} -- Note [Inlining addErrCtxt]
-addLandmarkErrCtxtM ctxt = pushCtxt (True, ctxt)
+addLandmarkErrCtxtM ctxt = pushCtxt (MkErrCtxt LandmarkUserSrcCode ctxt)
-- | NB. no op in generated code
-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr
@@ -1371,9 +1385,7 @@ pushCtxt ctxt = updLclEnv (updCtxt ctxt)
updCtxt :: ErrCtxt -> TcLclEnv -> TcLclEnv
-- Do not update the context if we are in generated code
-- See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr
-updCtxt ctxt env
- | lclEnvInGeneratedCode env = env
- | otherwise = addLclEnvErrCtxt ctxt env
+updCtxt ctxt env = addLclEnvErrCtxt ctxt env
popErrCtxt :: TcM a -> TcM a
popErrCtxt thing_inside = updLclEnv (\env -> setLclEnvErrCtxt (pop $ getLclEnvErrCtxt env) env) $
@@ -1834,11 +1846,17 @@ mkErrCtxt env ctxts
where
go :: Bool -> Int -> TidyEnv -> [ErrCtxt] -> TcM [ErrCtxtMsg]
go _ _ _ [] = return []
- go dbg n env ((is_landmark, ctxt) : ctxts)
- | is_landmark || n < mAX_CONTEXTS -- Too verbose || dbg
+ go dbg n env (MkErrCtxt LandmarkUserSrcCode ctxt : ctxts)
+ | n < mAX_CONTEXTS -- Too verbose || dbg
+ = do { (env', msg) <- liftZonkM $ ctxt env
+ ; rest <- go dbg n env' ctxts
+ ; return (msg : rest) }
+ | otherwise
+ = go dbg n env ctxts
+ go dbg n env (MkErrCtxt _ ctxt : ctxts)
+ | n < mAX_CONTEXTS -- Too verbose || dbg
= do { (env', msg) <- liftZonkM $ ctxt env
- ; let n' = if is_landmark then n else n+1
- ; rest <- go dbg n' env' ctxts
+ ; rest <- go dbg (n+1) env' ctxts
; return (msg : rest) }
| otherwise
= go dbg n env ctxts
=====================================
testsuite/tests/rebindable/rebindable6.stderr
=====================================
@@ -1,9 +1,8 @@
-
rebindable6.hs:110:17: error: [GHC-39999]
• Ambiguous type variable ‘t0’ arising from a do statement
prevents the constraint ‘(HasSeq
(IO a -> t0 -> IO b))’ from being solved.
- (maybe you haven't applied a function to enough arguments?)
+ (maybe you haven't applied a function to enough arguments?)
Relevant bindings include
g :: IO (Maybe b) (bound at rebindable6.hs:108:19)
f :: IO a (bound at rebindable6.hs:108:17)
@@ -28,7 +27,7 @@ rebindable6.hs:111:17: error: [GHC-39999]
• Ambiguous type variables ‘t1’, ‘t0’ arising from a do statement
prevents the constraint ‘(HasBind
(IO (Maybe b) -> (Maybe b -> t1) -> t0))’ from being solved.
- (maybe you haven't applied a function to enough arguments?)
+ (maybe you haven't applied a function to enough arguments?)
Relevant bindings include
g :: IO (Maybe b) (bound at rebindable6.hs:108:19)
test_do :: IO a -> IO (Maybe b) -> IO b
@@ -50,9 +49,9 @@ rebindable6.hs:111:17: error: [GHC-39999]
return b
rebindable6.hs:112:17: error: [GHC-39999]
- • Ambiguous type variable ‘t1’ arising from a use of ‘return’
+ • Ambiguous type variable ‘t1’ arising from a do statement
prevents the constraint ‘(HasReturn (b -> t1))’ from being solved.
- (maybe you haven't applied a function to enough arguments?)
+ (maybe you haven't applied a function to enough arguments?)
Relevant bindings include
b :: b (bound at rebindable6.hs:111:23)
g :: IO (Maybe b) (bound at rebindable6.hs:108:19)
@@ -71,3 +70,4 @@ rebindable6.hs:112:17: error: [GHC-39999]
= do f
Just (b :: b) <- g
return b
+
=====================================
testsuite/tests/typecheck/should_fail/DoExpansion1.stderr
=====================================
@@ -22,7 +22,7 @@ DoExpansion1.hs:15:54: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefaul
DoExpansion1.hs:19:21: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
• No instance for ‘Num String’ arising from the literal ‘1’
• In the first argument of ‘putStrLn’, namely ‘1’
- In the expression: putStrLn 1
+ In a stmt of a 'do' block: putStrLn 1
In the expression:
do putStrLn 1
putStrLn "r2"
@@ -31,7 +31,7 @@ DoExpansion1.hs:19:21: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefaul
DoExpansion1.hs:25:21: warning: [GHC-39999] [-Wdeferred-type-errors (in -Wdefault)]
• No instance for ‘Num String’ arising from the literal ‘2’
• In the first argument of ‘putStrLn’, namely ‘2’
- In the expression: putStrLn 2
+ In a stmt of a 'do' block: putStrLn 2
In the expression:
do putStrLn "r1"
putStrLn 2
=====================================
testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
=====================================
@@ -57,9 +57,7 @@ DoExpansion2.hs:34:22: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefaul
• The function ‘getVal’ is applied to two visible arguments,
but its type ‘Int -> IO String’ has only one
In the expression: getVal 3 4
- In the expression:
- do Just x <- getVal 3 4
- return x
+ In a stmt of a 'do' block: Just x <- getVal 3 4
DoExpansion2.hs:39:19: warning: [GHC-83865] [-Wdeferred-type-errors (in -Wdefault)]
• Couldn't match type ‘[Char]’ with ‘Int’
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc871fb970034810dc8854affdd642c…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc871fb970034810dc8854affdd642c…
You're receiving this email because of your account on gitlab.haskell.org.
1
0