From 99e0b3b81d2821f78adc6b422a6b3d1b5f825427 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 24 Sep 2018 14:02:49 -0400 Subject: [PATCH] fix bug in parsing extended colon-like operators (#29314) --- src/julia-parser.scm | 2 +- test/syntax.jl | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 9d832894f9bb1..45ea82252f2d7 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -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 ':)) diff --git a/test/syntax.jl b/test/syntax.jl index 4a0c7a390850f..90746786cd5bc 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -1728,3 +1728,10 @@ function test_26037() end end @test test_26037() === nothing # no UndefVarError + +# 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")