elm-tooling / tree-sitter-elm

Tree sitter implementation for elm
https://elm-tooling.github.io/tree-sitter-elm/
MIT License
74 stars 12 forks source link

nullary patterns in function heads cause syntax errors #123

Open BrianHicks opened 2 years ago

BrianHicks commented 2 years ago

Hello! I've got something a little weird. I'm making some tools with tree-sitter-elm and found that nullary patterns in function heads will cause a syntax error in tree-sitter-elm, but be accepted by Elm proper. Here's a SSCCE:

module Main exposing (..)

type Foo
    = Bar

fooToString : Foo -> String
fooToString Bar =
    "Bar"

Tree-sitter-elm will say there's a syntax error on line 9, column 13 (the Bar in fooToString Bar.) Changing Bar to _ resolves the problem.

Here it is in an Ellie, being compiled by Elm: https://ellie-app.com/hST6r7VtQjKa1

razzeee commented 2 years ago

I can reproduce this.

IntelliJ elm seems to have the same problem.

It's caused by this choice not allowing anything that starts with an uppercase. https://github.com/elm-tooling/tree-sitter-elm/blob/main/grammar.js#L209

https://github.com/klazuka/intellij-elm/blob/master/src/main/grammars/ElmParser.bnf#L185