haskell / haskell/happy

Explicitly set text encoding to utf-8?

Open
#337 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
322
Forks
86
PR merge metrics
No merged PRs in 30d

Description

I've been running into a build failure with ghc-lib-parser-9.12.2.20250421, where on a fresh docker image I get

```
*** Exception: compiler/GHC/Parser.y: hGetContents: invalid argument (cannot decode byte sequence starting from 226`:
```

The locale on this image is:

```
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
```

Setting `LC_ALL=C.UTF-8` gets rid of the error, but since Haskell source files (and transitively happy files) are [specified to be UTF-8](https://downloads.haskell.org/ghc/latest/docs/users_guide/separate_compilation.html#haskell-source-files), I wonder if the right thing to do could be to explicitly set the encoding for both happy input and output to UTF-8.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the shown POSIX locale and inspect how Happy handles input and output encoding, starting with compiler/GHC/Parser.y. The work is done when the affected build handles the UTF-8 source under that locale without requiring LC_ALL=C.UTF-8.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.