Skip to content

Commit 5612d66

Browse files
committed
Remove source's type annotation too
A JuliaLowering.SyntaxTree may have a line number node instead of a SourceFile as its location. Pushing the linenode through `node_to_expr` is strange and temporary, according to comments.
1 parent a55ac20 commit 5612d66

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/integration/expr.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ reverse_nontrivia_children(cursor) = Iterators.filter(should_include_node, Itera
7474
#
7575
# This function concatenating adjacent string chunks together as done in the
7676
# reference parser.
77-
function _string_to_Expr(cursor, source::SourceFile, txtbuf::Vector{UInt8}, txtbuf_offset::UInt32)
77+
function _string_to_Expr(cursor, source, txtbuf::Vector{UInt8}, txtbuf_offset::UInt32)
7878
ret = Expr(:string)
7979
args2 = Any[]
8080
i = 1
@@ -197,7 +197,7 @@ function _append_iterspec!(args::Vector{Any}, @nospecialize(ex))
197197
return args
198198
end
199199

200-
function parseargs!(retexpr::Expr, loc::LineNumberNode, cursor, source::SourceFile, txtbuf::Vector{UInt8}, txtbuf_offset::UInt32)
200+
function parseargs!(retexpr::Expr, loc::LineNumberNode, cursor, source, txtbuf::Vector{UInt8}, txtbuf_offset::UInt32)
201201
args = retexpr.args
202202
firstchildhead = head(cursor)
203203
firstchildrange::UnitRange{UInt32} = byte_range(cursor)
@@ -221,7 +221,8 @@ _expr_leaf_val(cursor::RedTreeCursor, txtbuf::Vector{UInt8}, txtbuf_offset::UInt
221221
# Extended in JuliaLowering to support `node_to_expr(::SyntaxTree, ...)`
222222

223223
# Convert `cursor` (SyntaxNode or RedTreeCursor) to an Expr
224-
function node_to_expr(cursor, source::SourceFile, txtbuf::Vector{UInt8}, txtbuf_offset::UInt32=UInt32(0))
224+
# `source` is a SourceFile, or if node was an Expr originally, a LineNumberNode
225+
function node_to_expr(cursor, source, txtbuf::Vector{UInt8}, txtbuf_offset::UInt32=UInt32(0))
225226
if !should_include_node(cursor)
226227
return nothing
227228
end
@@ -302,7 +303,7 @@ end
302303
firstchildhead::SyntaxHead,
303304
firstchildrange::UnitRange{UInt32},
304305
nodehead::SyntaxHead,
305-
source::SourceFile)
306+
source)
306307
args = retexpr.args
307308
k = kind(nodehead)
308309
endloc = source_location(LineNumberNode, source, last(srcrange))

0 commit comments

Comments
 (0)