Skip to content

Commit

Permalink
fix JuliaLang#16686, line number of call on catch line
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 1, 2016
1 parent 4904241 commit ff8560f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,8 @@
'(block)
#f
finalb)
(let* ((var (if nl #f (parse-eq* s)))
(let* ((loc (line-number-node s))
(var (if nl #f (parse-eq* s)))
(var? (and (not nl) (or (and (symbol? var) (not (eq? var 'false))
(not (eq? var 'true)))
(and (length= var 2) (eq? (car var) '$)))))
Expand All @@ -1259,7 +1260,7 @@
(loop (require-token s)
(if (or var? (not var))
catch-block
`(block ,(cadr catch-block) ,var ,@(cddr catch-block)))
`(block ,loc ,var ,@(cdr catch-block)))
(if var? var 'false)
finalb)))))
((and (eq? nxt 'finally)
Expand Down
15 changes: 15 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,18 @@ let isline(x) = isa(x,Expr) && x.head === :line
@test count(isline, parse("begin; x+2; end").args) == 1
@test count(isline, parse("begin; x+2; y+1; end").args) == 2
end

# issue #16686
@test parse("try x
catch test()
y
end") == Expr(:try,
Expr(:block,
Expr(:line, 1, :none),
:x),
false,
Expr(:block,
Expr(:line, 2, :none),
Expr(:call, :test),
Expr(:line, 3, :none),
:y))

0 comments on commit ff8560f

Please sign in to comment.