Skip to content

callStack produces call-stacks with duplicated backslashes on Windows when used with -XCPP

Summary

callStack produces call-stacks with duplicated backslashes on Windows when used with -XCPP.

Steps to reproduce

Given a source file src/Main.hs

module Main where

import GHC.Stack

main :: IO ()
main = putStrLn $ prettyCallStack foo

foo :: HasCallStack => CallStack
foo = callStack

run

$ runhaskell src/Main.hs
CallStack (from HasCallStack):
  foo, called at src\Main.hs:6:35 in main:Main
$ runhaskell -XCPP src/Main.hs
CallStack (from HasCallStack):
  foo, called at src\\Main.hs:6:35 in main:Main

(GitHub Action that reproduces the bug: https://github.com/sol/ghc-windows-call-stack-bug/runs/1728925783?check_suite_focus=true#step:3:10)

Expected behavior

The output of runhaskell -XCPP src/Main.hs should include src\Main.hs instead of src\\Main.hs.

Environment

  • GHC version used: 7.10.3
  • Operating System: Windows
  • System Architecture: x64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information