Skip to content

Commit

Permalink
add do in front-end deparser. fixes #17781 (#26840)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Apr 18, 2018
1 parent ca7e837 commit ab53067
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ast.scm
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@
""))
"")
(string.rep " " ilvl) "end"))
((do)
(let ((call (cadr e))
(args (cdr (cadr (caddr e))))
(body (caddr (caddr e))))
(deparse-block (string (deparse call) " do" (if (null? args) "" " ")
(deparse-arglist args))
(cdr body) ilvl)))
((struct)
(string (if (eq? (cadr e) 'true) "mutable " "")
"struct "
Expand Down
20 changes: 20 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1386,3 +1386,23 @@ end

# issue #26717
@test Meta.lower(@__MODULE__, :( :(:) = 2 )) == Expr(:error, "invalid assignment location \":(:)\"")

# issue #17781
let ex = Meta.lower(@__MODULE__, Meta.parse("
A = function (s, o...)
f(a, b) do
end
end,
B = function (s, o...)
f(a, b) do
end
end"))
@test isa(ex, Expr) && ex.head === :error
@test ex.args[1] == """
invalid assignment location "function (s, o...)
# none, line 3
f(a, b) do
# none, line 4
end
end\""""
end

0 comments on commit ab53067

Please sign in to comment.