panic: impossible happened: in GHC version 9.12.3 and 9.12.4
## Summary
Error messages:
The following occurred when building in [PostgREST CI](https://github.com/PostgREST/postgrest/actions/runs/25174434211/job/73810192594?pr=4861) when building with NixOS - MacOS 15 image from `github/actions`.
```
error: Cannot build '/nix/store/ywj2kyywb6a4mnxd51cggv7q3g721y7p-postgrest-15.drv'.
Reason: builder failed with exit code 1.
Output paths:
/nix/store/4cgygrggpmj3kmcjk8m18vpp1n8d8ha0-postgrest-15
/nix/store/i3pv1xz6rkykji43c6hcw0xc21cfd3w3-postgrest-15-bin
Last 25 log lines:
> <no location info>: error:
> panic! (the 'impossible' happened)
> GHC version 9.12.3:
> lookupGREInfo
> lookup failed: toUtf8
> Call stack:
> CallStack (from HasCallStack):
> callStackDoc, called at compiler/GHC/Utils/Panic.hs:190:37 in ghc-9.12.3-b311:GHC.Utils.Panic
> pprPanic, called at compiler/GHC/Rename/Env.hs:2026:15 in ghc-9.12.3-b311:GHC.Rename.Env
>
> Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
The following occurred when building with `--enable-profiling` in [PostgREST CI](https://github.com/PostgREST/postgrest/actions/runs/25174434187/job/73810761270?pr=4861).
```
[ 6 of 56] Compiling PostgREST.ApiRequest.Preferences ( src/PostgREST/ApiRequest/Preferences.hs, dist-prof/build/x86_64-linux/ghc-9.12.3/postgrest-15/build/PostgREST/ApiRequest/Preferences.o )
[ 7 of 56] Compiling PostgREST.Config.Proxy ( src/PostgREST/Config/Proxy.hs, dist-prof/build/x86_64-linux/ghc-9.12.3/postgrest-15/build/PostgREST/Config/Proxy.o, dist-prof/build/x86_64-linux/ghc-9.12.3/postgrest-15/build/PostgREST/Config/Proxy.dyn_o )
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.12.3:
lookupGREInfo
lookup failed: toS
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:190:37 in ghc-9.12.3-2625:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Rename/Env.hs:2026:15 in ghc-9.12.3-2625:GHC.Rename.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
and
```
[11 of 56] Compiling PostgREST.RangeQuery ( src/PostgREST/RangeQuery.hs, dist-prof/build/x86_64-linux/ghc-9.12.3/postgrest-15/build/PostgREST/RangeQuery.o, dist-prof/build/x86_64-linux/ghc-9.12.3/postgrest-15/build/PostgREST/RangeQuery.dyn_o )
<no location info>: error:
Failed to load dynamic interface file for Protolude.Panic:
Exception when reading interface file /home/runner/work/postgrest/postgrest/dist-prof/build/x86_64-linux/ghc-9.12.3/postgrest-15/l/protolude/build/protolude/Protolude/Panic.dyn_hi
/home/runner/work/postgrest/postgrest/dist-prof/build/x86_64-linux/ghc-9.12.3/postgrest-15/l/protolude/build/protolude/Protolude/Panic.dyn_hi: withBinaryFile: does not exist (No such file or directory)
[12 of 56] Compiling PostgREST.Response.GucHeader ( src/PostgREST/Response/GucHeader.hs, dist-prof/build/x86_64-linux/ghc-9.12.3/postgrest-15/build/PostgREST/Response/GucHeader.o )
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.12.3:
lookupGREInfo
lookup failed: toUtf8
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:190:37 in ghc-9.12.3-2625:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Rename/Env.hs:2026:15 in ghc-9.12.3-2625:GHC.Rename.Env
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
```
## Steps to reproduce
Not sure, but it involves building [protolude](https://github.com/protolude/protolude) library with GHC 9.12.3 and 9.12.4 from nixpkgs on MacOS 15, possibly with or without `--enable-profiling`.
## Expected behavior
It should compile without any issues.
## Environment
* GHC version used: GHC 9.12.3 and 9.12.4 from nixpkgs.
Optional:
* Operating System: MacOS - 15
* System Architecture: aarch64 or arm64 (not sure)
issue