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 3ebdf24
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ This section lists changes that do not have deprecation warnings.
* The `Diagonal` type definition has changed from `Diagonal{T}` to
`Diagonal{T,V<:AbstractVector{T}}` ([#22718]).

* Spaces are no longer allowed between `@` and the name of a macro in a macro call ([#22868]).

* Juxtaposition of a non-literal with a macro call (`x@macro`) is no longer valid syntax ([#22868]).

Library improvements
--------------------

Expand Down
6 changes: 5 additions & 1 deletion src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,8 @@
(define (juxtapose? s expr t)
(and (or (number? expr)
(large-number? expr)
(not (number? t)) ;; disallow "x.3" and "sqrt(2)2"
(and (not (number? t)) ;; disallow "x.3" and "sqrt(2)2"
(not (eqv? t #\@))) ;; disallow "x@time"
;; to allow x'y as a special case
#;(and (pair? expr) (memq (car expr) '(|'| |.'|))
(not (memv t '(#\( #\[ #\{))))
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 3ebdf24

Please sign in to comment.