diff --git a/base/expr.jl b/base/expr.jl index 234085d9c9774..8528ebd1d26e1 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -33,6 +33,9 @@ macro gensym(names...) return blk end +## line numbers ## +convert(::Type{LineNumberNode}, lin::Core.LineInfoNode) = LineNumberNode(Int(lin.line), lin.file) + ## expressions ## isexpr(@nospecialize(ex), head::Symbol) = isa(ex, Expr) && ex.head === head diff --git a/test/core.jl b/test/core.jl index 087234abe1a94..5b7c302d4df48 100644 --- a/test/core.jl +++ b/test/core.jl @@ -8044,3 +8044,7 @@ end # `SimpleVector`-operations should be concrete-eval eligible @test Core.Compiler.is_foldable(Base.infer_effects(length, (Core.SimpleVector,))) @test Core.Compiler.is_foldable(Base.infer_effects(getindex, (Core.SimpleVector,Int))) + +let lin = Core.LineInfoNode(Base, first(methods(convert)), :foo, Int32(5), Int32(0)) + @test convert(LineNumberNode, lin) == LineNumberNode(5, :foo) +end