Elm Exactly
Results / elm /

WeirdElseBranchElseNotIndentedTest

Tags:elm19-compile-errorelm-spec

Checks, in A Standard Definition of Elm?:restriction core-layout-rule

Not translated into Lean for the mechanisation of the book: see why.

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
An `if` inside a `let` binding whose `else` sits at the binding's own column, to the left of
its `if`, is rejected with a WEIRD ELSE BRANCH error.

The `else` keyword has to be indented further than the start of the `let` binding `y`, and
here it is level with it.

Results

elm-0.19.1

pass
Output
Compiling ...-- WEIRD ELSE BRANCH ---------------- src/WeirdElseBranchElseNotIndentedTest.elm

I was partway through an `if` expression when I got stuck here:

20|             if True then
21|                 1
22|         else
            ^^^^
I think this else keyword needs to be indented more. Try adding some spaces
before it.

Detected problems in 1 module.

elm-0.19.2

pass
Output
Compiling ...-- WEIRD ELSE BRANCH ---------------- src/WeirdElseBranchElseNotIndentedTest.elm

I was partway through an `if` expression when I got stuck here:

20|             if True then
21|                 1
22|         else
            ^^^^
I think this else keyword needs to be indented more. Try adding some spaces
before it.

Detected problems in 1 module.

elm-0.19.3

pass
Output
Compiling ...-- WEIRD ELSE BRANCH ---------------- src/WeirdElseBranchElseNotIndentedTest.elm

I was partway through an `if` expression when I got stuck here:

20|             if True then
21|                 1
22|         else
            ^^^^
I think this else keyword needs to be indented more. Try adding some spaces
before it.

Detected problems in 1 module.

lamdera-1.5.0

pass
Output
Detected problems in 1 module.
-- WEIRD ELSE BRANCH ---------------- src/WeirdElseBranchElseNotIndentedTest.elm

I was partway through an `if` expression when I got stuck here:

20|             if True then
21|                 1
22|         else
            ^^^^
I think this else keyword needs to be indented more. Try adding some spaces
before it.

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm/WeirdElseBranchElseNotIndentedTest] in its title.

Source

The -- CHECK: lines give the expected output.

module WeirdElseBranchElseNotIndentedTest exposing (main)
{-| An `if` inside a `let` binding whose `else` sits at the binding's own column, to the left of
its `if`, is rejected with a WEIRD ELSE BRANCH error.
The `else` keyword has to be indented further than the start of the `let` binding `y`, and
here it is level with it.
-}
-- TAGS: elm19-compile-error
-- TAGS: elm-spec, core-layout-rule
-- COMPILE-ERROR: WEIRD ELSE BRANCH
-- CHECK: -- WEIRD ELSE BRANCH -
main =
let
y =
if True then
1
else
2
in
y

Lean translation

No reduced program for Lean's evaluator: the test expects a compile error, so it has no meaning to evaluate. Static semantics: expected to be rejected, and eco's parser rejects it too. See the Lean mechanisation for which tests are in Lean, and why.