From c5d222202169cd7cd064a61afe864f70db6ab1a4 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 1 Aug 2016 16:56:05 -0400 Subject: [PATCH] fix #17668, deprecation for `for ( ... )` --- NEWS.md | 3 +++ src/julia-parser.scm | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index d4fc9a2ee0aae..f5c7b0cd3d0a3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 -------------------- diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 3bad336c80bdc..0e21544ff3904 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -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) @@ -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)