Skip to content

GHCi panics on Windows when terminal set to UTF-8 and four-byte characters are used

Summary

When I run GHCi on Windows after setting the terminal to UTF-8, I get a GHC panic.

 Alexis Williams@TRUELAB > ~\..\cmder_mini > chcp                       
Active code page: 437                                                   
 Alexis Williams@TRUELAB > ~\..\cmder_mini > ghci                       
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help           
Loaded GHCi configuration from C:\Users\Alexis Williams\.ghci           
[34mλ🐀 [0m :q                                                       
Leaving GHCi.                                                           
 Alexis Williams@TRUELAB > ~\..\cmder_mini > chcp 65001                 
Active code page: 65001                                                 
 Alexis Williams@TRUELAB > ~\..\cmder_mini > ghci                       
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help           
Loaded GHCi configuration from C:\Users\Alexis Williams\.ghci           
ghc.exe: panic! (the 'impossible' happened)                             
  (GHC version 8.6.5 for x86_64-unknown-mingw32):                       
        Enum.toEnum{Word16}: tag (128000) is outside of bounds (0,65535)
                                                                        
Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug 

I know that the gibberish output with the normal codepage is a known issue, but the panic seems rather more serious to my mind.

Steps to reproduce

  1. Run chcp 65001 in Powershell or cmd.exe
  2. Add a .ghci that uses a four-byte character such as an emoji.
    :set prompt "\ESC[34mλ🐀 \ESC[0m "
    :set prompt-cont "\ESC[34mλ🐁 \ESC[0m "
  3. Run ghci

Expected behavior

I would expect either the same incorrect output due to the known bug or correct output to the terminal.

Environment

  • GHC version used: 8.6.5

Optional:

  • Operating System: Windows
  • System Architecture: x86_64
Edited by Alexis Williams
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information