Skip to content

Commit

Permalink
fix #17668, deprecation for for ( ... )
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Aug 1, 2016
1 parent 07f93ee commit ebb95e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ Language changes
* Dictionary comprehension syntax `[ a=>b for x in y ]` is deprecated.
Use `Dict(a=>b for x in y)` instead ([#16510]).

* Parentheses are no longer allowed around iteration specifications, e.g.
`for (i = 1:n)` ([#17668]).

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

Expand Down
10 changes: 9 additions & 1 deletion src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,8 @@

;; as above, but allows both "i=r" and "i in r"
(define (parse-iteration-spec s)
(let* ((lhs (parse-pipes s))
(let* ((paren? (eqv? (require-token s) #\())
(lhs (parse-pipes s))
(t (peek-token s)))
(cond ((memq t '(= in ∈))
(take-token s)
Expand All @@ -1428,6 +1429,13 @@
`(= ,lhs ,rhs)))
((and (eq? lhs ':) (closing-token? t))
':)
((and paren? (length= lhs 4) (eq? (car lhs) 'call)
(memq (cadr lhs) '(in ∈)))
(syntax-deprecation s "for (...)" "for ...")
`(= ,@(cddr lhs)))
((and paren? (length= lhs 3) (eq? (car lhs) '=))
(syntax-deprecation s "for (...)" "for ...")
lhs)
(else (error "invalid iteration specification")))))

(define (parse-comma-separated-iters s)
Expand Down

0 comments on commit ebb95e7

Please sign in to comment.