From 7366afd43777882ec7a0b132180163bd0bb920a0 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Wed, 19 Jul 2017 12:25:57 -0400 Subject: [PATCH] fix #22868, parse errors for `x@time` and `@ time` --- src/julia-parser.scm | 4 ++++ test/parse.jl | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/julia-parser.scm b/src/julia-parser.scm index f9048eb39f52e3..1e351d7e4ba9ba 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -987,6 +987,7 @@ (or (not (string? expr)) ;; issue #20575 (error "cannot juxtapose string literal")) (not (initial-reserved-word? t)) + (not (eqv? t #\@)) (not (and (pair? expr) (syntactic-unary-op? (car expr)))) ;; TODO: this would disallow juxtaposition with 0, which is ambiguous ;; with e.g. hex literals `0x...`. however this is used for `0im`, which @@ -2160,6 +2161,9 @@ ;; macro call ((eqv? t #\@) (take-token s) + (let ((nxt (peek-token s))) + (if (ts:space? s) + (disallowed-space '@ nxt))) (with-space-sensitive (let ((startloc (line-number-node s)) (head (if (eq? (peek-token s) '|.|) diff --git a/test/parse.jl b/test/parse.jl index 357e70ce711add..5bd36147945b47 100644 --- a/test/parse.jl +++ b/test/parse.jl @@ -1247,3 +1247,7 @@ end === (3, String) # issue #22840 @test parse("[:a :b]") == Expr(:hcat, QuoteNode(:a), QuoteNode(:b)) + +# issue #22868 +@test_throws ParseError parse("x@time 2") +@test_throws ParseError parse("@ time")