Skip to content

Commit a89f3ab

Browse files
authored
Merge pull request #384 from julia-vscode/sp/fix-curly-where-comp-parsing
fix: proper curly parsing in where with comparison operator
2 parents 84660f9 + c127f30 commit a89f3ab

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/components/operators.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,13 @@ end
360360

361361
# parse where
362362
function parse_operator_where(ps::ParseState, ret::EXPR, op::EXPR, setscope=true)
363-
nextarg = @precedence ps LazyAndOp @closer ps :inwhere parse_expression(ps)
363+
# https://github.com/JuliaLang/JuliaSyntax.jl/issues/395
364+
prec = VERSION > v"1.10-" && kindof(ps.nt) == Tokens.LBRACE ? WhereOp : LazyAndOp
365+
nextarg = @precedence ps prec @closer ps :inwhere parse_expression(ps)
364366
if headof(nextarg) === :braces
365367
pushfirst!(nextarg.args, ret)
366368
pushfirst!(nextarg.trivia, op)
367-
ret = EXPR(:where, nextarg.args,nextarg.trivia)
369+
ret = EXPR(:where, nextarg.args, nextarg.trivia)
368370
else
369371
ret = EXPR(:where, EXPR[ret, nextarg], EXPR[op])
370372
end

test/parser/test_operators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ end
164164
@test "a = b where c = d" |> test_expr
165165
@test "a = b where c" |> test_expr
166166
@test "b where c = d" |> test_expr
167+
@test "b where {c} == d" |> test_expr
167168

168169
@test "a ? b where c : d" |> test_expr
169170
if VERSION >= v"1.6"

0 commit comments

Comments
 (0)