Skip to content

Commit 9134dd3

Browse files
committed
typeassert Expr constructor return value
Type stability fix: makes the return value of the `Expr` constructor method infer as `Expr`. Not sure if this could be fixed at a deeper level of the call stack instead. Works around issue JuliaLang/julia#42372 in the case of this method.
1 parent 012d931 commit 9134dd3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/integration/expr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,4 +668,4 @@ function to_expr(node)
668668
return fixup_Expr_child(wrapper_head, node_to_expr(node, source, txtbuf, UInt32(txtbuf_offset)), false)
669669
end
670670

671-
Base.Expr(node::SyntaxNode) = to_expr(node)
671+
Base.Expr(node::SyntaxNode) = to_expr(node)::Expr

test/expr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,6 @@ end
838838

839839
@testset "SyntaxNode->Expr conversion" begin
840840
src = repeat('a', 1000) * '\n' * "@hi"
841-
@test Expr(parsestmt(SyntaxNode, SubString(src, 1001:lastindex(src)))) ==
841+
@test (@inferred Expr(parsestmt(SyntaxNode, SubString(src, 1001:lastindex(src))))) ==
842842
Expr(:macrocall, Symbol("@hi"), LineNumberNode(2))
843843
end

0 commit comments

Comments
 (0)