avh4 / elm-format

elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide
BSD 3-Clause "New" or "Revised" License
1.31k stars 148 forks source link

"infix" is not considered a valid identifier #728

Closed jfmengels closed 1 year ago

jfmengels commented 3 years ago

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 3 years ago

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 3 years ago

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 1 year ago

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 1 year ago

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.