Skip to content

Commit

Permalink
fix bug in parsing extended colon-like operators (#29314)
Browse files Browse the repository at this point in the history
(cherry picked from commit 99e0b3b)
  • Loading branch information
JeffBezanson authored and KristofferC committed Feb 11, 2019
1 parent d9b7f1a commit b3f1310
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@
(first? #t))
(let* ((t (peek-token s))
(spc (ts:space? s)))
(cond ((and first? (eq? t '|..|))
(cond ((and first? (is-prec-colon? t) (not (eq? t ':)))
(take-token s)
`(call ,t ,ex ,(parse-expr s)))
((and range-colon-enabled (eq? t ':))
Expand Down
7 changes: 7 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1718,3 +1718,10 @@ f28900(; kwarg) = kwarg
let g = @foo28900 f28900(kwarg = x->2x)
@test g(10) == 20
end

# range and interval operators
@test Meta.parse("1…2") == Expr(:call, :, 1, 2)
@test Meta.parse("1⁝2") == Expr(:call, :, 1, 2)
@test Meta.parse("1..2") == Expr(:call, :.., 1, 2)
# we don't parse chains of these since the associativity and meaning aren't clear
@test_throws ParseError Meta.parse("1..2..3")

0 comments on commit b3f1310

Please sign in to comment.