Skip to content

Commit ebb95e7

Browse files
committed
fix #17668, deprecation for for ( ... )
1 parent 07f93ee commit ebb95e7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ Language changes
9898
* Dictionary comprehension syntax `[ a=>b for x in y ]` is deprecated.
9999
Use `Dict(a=>b for x in y)` instead ([#16510]).
100100

101+
* Parentheses are no longer allowed around iteration specifications, e.g.
102+
`for (i = 1:n)` ([#17668]).
103+
101104
Library improvements
102105
--------------------
103106

src/julia-parser.scm

+9-1
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,8 @@
14151415

14161416
;; as above, but allows both "i=r" and "i in r"
14171417
(define (parse-iteration-spec s)
1418-
(let* ((lhs (parse-pipes s))
1418+
(let* ((paren? (eqv? (require-token s) #\())
1419+
(lhs (parse-pipes s))
14191420
(t (peek-token s)))
14201421
(cond ((memq t '(= in ∈))
14211422
(take-token s)
@@ -1428,6 +1429,13 @@
14281429
`(= ,lhs ,rhs)))
14291430
((and (eq? lhs ':) (closing-token? t))
14301431
':)
1432+
((and paren? (length= lhs 4) (eq? (car lhs) 'call)
1433+
(memq (cadr lhs) '(in ∈)))
1434+
(syntax-deprecation s "for (...)" "for ...")
1435+
`(= ,@(cddr lhs)))
1436+
((and paren? (length= lhs 3) (eq? (car lhs) '=))
1437+
(syntax-deprecation s "for (...)" "for ...")
1438+
lhs)
14311439
(else (error "invalid iteration specification")))))
14321440

14331441
(define (parse-comma-separated-iters s)

0 commit comments

Comments
 (0)