Skip to content

Commit

Permalink
fix #22868, parse errors for x@time and @ time
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 19, 2017
1 parent 7c045f0 commit 7366afd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) '|.|)
Expand Down
4 changes: 4 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 7366afd

Please sign in to comment.