Elm-format: Removal of parens leads to invalid code.

Created on 11 Oct 2016  路  8Comments  路  Source: avh4/elm-format

module MinusErr exposing (..)


errFun : Int -> Int
errFun x =
    case x of
        (-1) ->
            0

        (-2) ->
            0

        _ ->
            1

compiles but after elm-format is converted to:

module MinusErr exposing (..)


errFun : Int -> Int
errFun x =
    case x of
        -1 ->
            0

        -2 ->
            0

        _ ->
            1

which does not compile.

bug

All 8 comments

Good catch!

I have accidentally reported this in elm-dev 0.18 topic as a parser error.

Shouldn't the formatted version be legal?

It seems to be illegal in 0.17.1 as well, so regardless of whether the compiler changes to allow it in the future, I think it's good for elm-format to work around it until then.

Is the version without parens legal in Elm 0.18?

It is still illegal in final 0.18 release.

This is also the case for Floats, as well as Ints. Interestingly, it is allowed by elm-compiler for the first case clause, but not for subsequent case clauses.

FYI, the relevant elm-compiler issue is https://github.com/elm-lang/elm-compiler/issues/1261

Fixed in 5ee5460...784de8f. This will be included in 0.5.2-alpha.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rtfeldman picture rtfeldman  路  4Comments

mordrax picture mordrax  路  6Comments

conradwt picture conradwt  路  8Comments

rtfeldman picture rtfeldman  路  7Comments

yonigibbs picture yonigibbs  路  7Comments