elm-format icon indicating copy to clipboard operation
elm-format copied to clipboard

adjacent let blocks should be joined

Open avh4 opened this issue 5 years ago • 3 comments

let
    a = 1
in
let
   b = 2
in
a + b

should merge the two blocks of definitions. Are there any cases where this changes the meaning of the code?

avh4 avatar Oct 02 '18 07:10 avh4

This might be an issue in Elm <0.19 where shadowing is allowed.

Valid Elm 0.18:

let a = 1
in
let a = 2
in a

Not valid Elm:

let a = 1
    a = 2
in a

We get the following error message in 0.18:

-- DUPLICATE DEFINITION ----------------------------------------------- Test.elm

There are multiple values named `a` in this let-expression.

11|         a =
            ^
Search through this let-expression, find all the values named `a`, and give each
of them a unique name.

Detected errors in 1 module.   

basile-henry avatar Oct 02 '18 08:10 basile-henry

Perhaps it's as simple as just checking if the adjacent blocks are disjoint (have no shared variable names).

ocharles avatar Oct 07 '18 22:10 ocharles

Working on this (:

thomasin avatar Oct 16 '20 18:10 thomasin