Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Elm/Parser/Expression.elm
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,9 @@ negationOperation =
"}" ->
negationAfterMinus

"," ->
negationAfterMinus

-- TODO only for tests
"" ->
negationAfterMinus
Expand Down
17 changes: 17 additions & 0 deletions tests/Elm/Parser/ExpressionTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,23 @@ all =
(Node { start = { row = 1, column = 1 }, end = { row = 1, column = 3 } }
(Negation (Node { start = { row = 1, column = 2 }, end = { row = 1, column = 3 } } (FunctionOrValue [] "x")))
)
, test "negated expression after comma" <|
\() ->
"(0,-x)"
|> expectAst
(Node { start = { row = 1, column = 1 }, end = { row = 1, column = 7 } }
(TupledExpression
[ Node { start = { row = 1, column = 2 }, end = { row = 1, column = 3 } }
(Integer 0)
, Node { start = { row = 1, column = 4 }, end = { row = 1, column = 6 } }
(Negation
(Node { start = { row = 1, column = 5 }, end = { row = 1, column = 6 } }
(FunctionOrValue [] "x")
)
)
]
)
)
, test "negated expression in application" <|
\() ->
"toFloat -5"
Expand Down