avh4/elm-format

"infix" is not considered a valid identifier

jfmengels opened this issue · 4 comments

elm-format can't seem to parse files where variables are named infix, which seems to be a valid Elm identifier (see https://ellie-app.com/cmX9yY86Dd9a1)

SSCCE

module A exposing (..)
infix = "infix"

and

module A exposing (..)
fn infix = infix

(and probably in other places like patterns, ...)

avh4 commented

Thanks! I'm guessing this is probably a change from Elm 0.18 -> Elm 0.19.

"infix" is still a top-level keyword in Elm 0.19 https://github.com/elm/core/blob/1.0.5/src/Basics.elm#L71 but I guess the parser needs to backtrack if it doesn't succeed up through the Int for the operator precedence. (Note that infix right ... = ... is still a valid function definition.)

avh4 commented

help wanted: working on this would involve adding a new test case in tests/test-files/good/Elm-0.19/ and changing the implementation in elm-format-lib/src/Parser/Declaration.hs#infixDecl_0_19, and considering if there are any other edge cases or interactions with Elm <=0.18.

avh4 commented

This should be solved when we upgrade to the new parser. I haven't heard that this is a super critical issue for anyone, so I'm going to postpone to the v0.10.0 milestone.

avh4 commented

Use in patterns, expressions, types, and let declarations appears to currently work (0.8.6). It's only as a top-level declaration that it currently fails.