Skip to content

Commit 07f93ee

Browse files
committed
fix #17701, better error message for i == 3 && i+=1
1 parent fc3cbc9 commit 07f93ee

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/ast.scm

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"")))
6161
((comparison) (apply string (map deparse (cdr e))))
6262
((in) (string (deparse (cadr e)) " in " (deparse (caddr e))))
63-
((ssavalue) (string "SSAValue(" (cdr e) ")"))
63+
((ssavalue) (string "SSAValue(" (cadr e) ")"))
6464
((line) (if (length= e 2)
6565
(string "# line " (cadr e))
6666
(string "# " (caddr e) ", line " (cadr e))))

src/julia-syntax.scm

+3
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,9 @@
14691469
`(block ,@(cdr e)
14701470
,(expand-update-operator op op= (car e) rhs T))))
14711471
(else
1472+
(if (and (pair? lhs)
1473+
(not (memq (car lhs) '(|.| tuple vcat typed_hcat typed_vcat))))
1474+
(error (string "invalid assignment location \"" (deparse lhs) "\"")))
14721475
(expand-update-operator- op op= lhs rhs declT))))
14731476

14741477
(define (lower-update-op e)

test/parse.jl

+2
Original file line numberDiff line numberDiff line change
@@ -648,3 +648,5 @@ for op in ["+", "-", "\$", "|", ".+", ".-", "*", ".*"]
648648
@test_throws ParseError parse("$op in [+, -]")
649649
end
650650

651+
# issue #17701
652+
@test expand(:(i==3 && i+=1)) == Expr(:error, "invalid assignment location \"==(i,3)&&i\"")

0 commit comments

Comments
 (0)