haskell / haskell/error-messages

Parse Error: missing closing bracket points to wrong location

Open
#553 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
76
Forks
19
PR merge metrics
No merged PRs in 30d

Description

Given this Haskell code in *temp.hs*:

```haskell
x :: [Char
x = 1
```

GHC error message is:

```console
$ ghc temp.hs
[1 of 2] Compiling Main ( temp.hs, temp.o )
temp.hs:2:1: error: [GHC-58481]
parse error (possibly incorrect indentation or mismatched brackets)
|
2 | x = 1
| ^
```

The error points to the start of the type definition line `x = 1`, which misleads us into thinking it's a line indentation issue.
It should instead point to the end of the previous (type definition) line `x :: [Char` and say that a closing square bracket `]` was expected.

This would make the error message much better and help in debugging.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the diagnostic with the Haskell code in temp.hs and the ghc command shown. Trace how the parser reports the missing bracket and compare the reported location and message with the issue's expected end-of-line location and missing ] wording; done means the diagnostic points to the incomplete type definition rather than x = 1.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.