Skip to content

Commit

Permalink
Make line numbers worse for compatibilty
Browse files Browse the repository at this point in the history
This is a simple fix for the tests, but a better solution is to make
Expr equivalence more permissive to accommodate having better line
information in the new parser!
  • Loading branch information
c42f committed Jul 24, 2024
1 parent 5253bf4 commit 6eab9b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,7 @@ function _internal_node_to_Expr(source, srcrange, head, childranges, childheads,
if has_flags(head, SHORT_FORM_FUNCTION_FLAG)
a2 = args[2]
if !@isexpr(a2, :block)
body_loc = source_location(LineNumberNode, source, first(childranges[2]))
args[2] = Expr(:block, body_loc, a2)
args[2] = Expr(:block, a2)
end
headsym = :(=)
else
Expand Down
2 changes: 2 additions & 0 deletions test/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ tests = [
"f(x) .= 1" => "(.= (call f x) 1)"
"f(x) = 1" => "(function-= (call f x) 1)"
"f(x)::T = 1" => "(function-= (::-i (call f x) T) 1)"
"f(x) where S where U = 1" => "(function-= (where (where (call f x) S) U) 1)"
"(f(x)::T) where S = 1" => "(function-= (where (parens (::-i (call f x) T)) S) 1)"
"f(x) = 1 = 2" => "(function-= (call f x) (= 1 2))" # Should be a warning!
],
JuliaSyntax.parse_pair => [
"a => b" => "(call-i a => b)"
Expand Down

0 comments on commit 6eab9b6

Please sign in to comment.