Skip to content

Commit

Permalink
fix JuliaLang#17701, better error message for i == 3 && i+=1
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and mfasi committed Sep 5, 2016
1 parent 1aeaf30 commit 5e5f490
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast.scm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"")))
((comparison) (apply string (map deparse (cdr e))))
((in) (string (deparse (cadr e)) " in " (deparse (caddr e))))
((ssavalue) (string "SSAValue(" (cdr e) ")"))
((ssavalue) (string "SSAValue(" (cadr e) ")"))
((line) (if (length= e 2)
(string "# line " (cadr e))
(string "# " (caddr e) ", line " (cadr e))))
Expand Down
3 changes: 3 additions & 0 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,9 @@
`(block ,@(cdr e)
,(expand-update-operator op op= (car e) rhs T))))
(else
(if (and (pair? lhs)
(not (memq (car lhs) '(|.| tuple vcat typed_hcat typed_vcat))))
(error (string "invalid assignment location \"" (deparse lhs) "\"")))
(expand-update-operator- op op= lhs rhs declT))))

(define (lower-update-op e)
Expand Down
2 changes: 2 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -648,3 +648,5 @@ for op in ["+", "-", "\$", "|", ".+", ".-", "*", ".*"]
@test_throws ParseError parse("$op in [+, -]")
end

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

0 comments on commit 5e5f490

Please sign in to comment.