Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a8a80b8

Browse files
committedMay 31, 2018
deprecate assignment inside square bracket expressions
for #25631
1 parent 8b3849e commit a8a80b8

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed
 

‎NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ Language changes
214214

215215
* `` (`\dots`) and `` (`\tricolon`) are now parsed as binary operators ([#26262]).
216216

217+
* Assignment syntax (`a=b`) inside square bracket expressions (e.g. `A[...]`, `[x, y]`)
218+
is deprecated. It will likely be reclaimed in a later version for passing keyword
219+
arguments. Note this does not affect updating operators like `+=` ([#25631]).
220+
217221
Breaking changes
218222
----------------
219223

‎src/julia-syntax.scm

+20-2
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,8 @@
20032003
(let ((a (cadr lhs))
20042004
(idxs (cddr lhs))
20052005
(rhs (caddr e)))
2006+
(if (any assignment? idxs)
2007+
(syntax-deprecation "assignment inside indexing" "" #f))
20062008
(let* ((reuse (and (pair? a)
20072009
(contains (lambda (x) (eq? x 'end))
20082010
idxs)))
@@ -2061,6 +2063,8 @@
20612063
'ref
20622064
(lambda (e)
20632065
(let ((args (cddr e)))
2066+
(if (any assignment? args)
2067+
(syntax-deprecation "assignment inside indexing" "" #f))
20642068
(if (has-parameters? args)
20652069
(error "unexpected semicolon in array expression")
20662070
(expand-forms (partially-expand-ref e)))))
@@ -2069,6 +2073,8 @@
20692073
(lambda (e)
20702074
(if (has-parameters? (cddr e))
20712075
(error (string "unexpected semicolon in \"" (deparse e) "\"")))
2076+
(if (any assignment? (cddr e))
2077+
(syntax-deprecation "assignment inside T{ }" "" #f))
20722078
(let* ((p (extract-implicit-whereparams e))
20732079
(curlyparams (car p))
20742080
(whereparams (cdr p)))
@@ -2241,14 +2247,21 @@
22412247
(lambda (e)
22422248
(if (has-parameters? (cdr e))
22432249
(error "unexpected semicolon in array expression"))
2250+
(if (any assignment? (cdr e))
2251+
(syntax-deprecation "assignment inside [ ]" "" #f))
22442252
(expand-forms `(call (top vect) ,@(cdr e))))
22452253

22462254
'hcat
2247-
(lambda (e) (expand-forms `(call (top hcat) ,@(cdr e))))
2255+
(lambda (e)
2256+
(if (any assignment? (cdr e))
2257+
(syntax-deprecation "assignment inside [ ]" "" #f))
2258+
(expand-forms `(call (top hcat) ,@(cdr e))))
22482259

22492260
'vcat
22502261
(lambda (e)
22512262
(let ((a (cdr e)))
2263+
(if (any assignment? a)
2264+
(syntax-deprecation "assignment inside [ ]" "" #f))
22522265
(if (has-parameters? a)
22532266
(error "unexpected semicolon in array expression")
22542267
(expand-forms
@@ -2267,12 +2280,17 @@
22672280
`(call (top vcat) ,@a))))))
22682281

22692282
'typed_hcat
2270-
(lambda (e) (expand-forms `(call (top typed_hcat) ,@(cdr e))))
2283+
(lambda (e)
2284+
(if (any assignment? (cddr e))
2285+
(syntax-deprecation "assignment inside T[ ]" "" #f))
2286+
(expand-forms `(call (top typed_hcat) ,@(cdr e))))
22712287

22722288
'typed_vcat
22732289
(lambda (e)
22742290
(let ((t (cadr e))
22752291
(a (cddr e)))
2292+
(if (any assignment? (cddr e))
2293+
(syntax-deprecation "assignment inside T[ ]" "" #f))
22762294
(expand-forms
22772295
(if (any (lambda (x)
22782296
(and (pair? x) (eq? (car x) 'row)))

0 commit comments

Comments
 (0)
Please sign in to comment.