gren-lang / gren-lang/compiler

Bad error message caused by let expression with too little indentation

Open
#235 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

accepted bug
Dominant language
Haskell
Stars
503
Forks
29
PR merge metrics
No merged PRs in 30d

Description

test =
  let n =
    identity (2 + 3)
  in n

will give the error:

-- UNFINISHED DEFINITION --------------------------------------------- Main.gren

I got stuck while parsing the `n` definition:

2|   let n = 
            ^
I was expecting to see an expression next. What is it equal to?

Here is a valid definition (with a type annotation) for reference:

    greet : String -> String
    greet name =
      "Hello " ++ name ++ "!"

which is not helpful because it suggests the same idiom of newline + 2 spaces indent after the equal sign, which happens to be valid in a function definition but not in a let expression where you need 5 or more spaces.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported snippet and compare its diagnostic with the valid function-definition example. Start by locating the compiler's parser or error-reporting entry point for unfinished let definitions. Done means the message explains the indentation requirement and no longer recommends the misleading two-space layout.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.