From 6eab9b62ddb89778dbfb4438bf16f892d058c1a9 Mon Sep 17 00:00:00 2001 From: Claire Foster Date: Wed, 24 Jul 2024 17:10:40 +1000 Subject: [PATCH] Make line numbers worse for compatibilty 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! --- src/expr.jl | 3 +-- test/parser.jl | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/expr.jl b/src/expr.jl index 3bf288ca..988da328 100644 --- a/src/expr.jl +++ b/src/expr.jl @@ -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 diff --git a/test/parser.jl b/test/parser.jl index ab5e3f68..fa286633 100644 --- a/test/parser.jl +++ b/test/parser.jl @@ -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)"