Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UndefVarError: T not defined in extract_inner_type #506

Closed
jishnub opened this issue Sep 20, 2023 · 0 comments · Fixed by #508
Closed

UndefVarError: T not defined in extract_inner_type #506

jishnub opened this issue Sep 20, 2023 · 0 comments · Fixed by #508

Comments

@jishnub
Copy link
Contributor

jishnub commented Sep 20, 2023

julia> f(i) = i > 0 ? i : 0.0
f (generic function with 1 method)

julia> @descend_code_warntype (() -> [f(i) for i in 1:2])()
(::var"#15#17")() @ Main REPL[60]:1
┌ Warning: couldn't retrieve source of (::var"#15#17")() @ Main REPL[60]:1
└ @ TypedSyntax ~/.julia/packages/TypedSyntax/LVzdW/src/node.jl:36
Variables
  #self#::Core.Const(var"#15#17"())
  #16::var"#16#18"

Body::Union{Vector{Int64}, Vector{Real}}
    @ REPL[60]:1 within `#15`
1 ─      (#16 = %new(Main.:(var"#16#18")))%2 = #16::Core.Const(var"#16#18"())%3 = (1:2)::Core.Const(1:2)
│   %4 = Base.Generator(%2, %3)::Core.Const(Base.Generator{UnitRange{Int64}, var"#16#18"}(var"#16#18"(), 1:2))
│   %5 = Base.collect(%4)::Union{Vector{Int64}, Vector{Real}}
└──      return %5
Select a call to descend into or  to ascend. [q]uit. [b]ookmark.
Toggles: [w]arn, [h]ide type-stable statements, [t]ype annotations, [s]yntax highlight for Source/LLVM/Native, [j]ump to source always.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
   %3 = < concrete eval > Colon(::Core.Const(1),::Core.Const(2))::Core.Const(1:2)
   %4 = < concrete eval > Generator(::Core.Const(var"#16#18"()),::Core.Const(1:2))::%5 = < constprop > collect(::Core.Const(Base.Generator{UnitRange{Int64}, var"#16#18"}(var"#16#18"(), 1:2)))::
   
collect(itr::Base.Generator) @ Base ~/packages/julias/julia-1.9/share/julia/base/array.jl:775
ERROR: UndefVarError: `T` not defined
Stacktrace:
  [1] extract_inner_type(#unused#::Type{Type{AbstractArray{var"#s91"<:Real, 1}}})
    @ TypedSyntax ~/.julia/packages/TypedSyntax/LVzdW/src/show.jl:98
  [2] type_annotation_mode(node::JuliaSyntax.TreeNode{TypedSyntax.TypedSyntaxData}, T::Any; type_annotations::Bool, hide_type_stable::Bool)
    @ TypedSyntax ~/.julia/packages/TypedSyntax/LVzdW/src/show.jl:104
  [3] type_annotation_mode
    @ ~/.julia/packages/TypedSyntax/LVzdW/src/show.jl:99 [inlined]
  [4] show_src_expr(io::IOContext{IOBuffer}, node::JuliaSyntax.TreeNode{TypedSyntax.TypedSyntaxData}, position::Int64, pre::String, pre2::String; type_annotations::Bool, iswarn::Bool, hide_type_stable::Bool, nd::Int64)
    @ TypedSyntax ~/.julia/packages/TypedSyntax/LVzdW/src/show.jl:79
  [5] show_src_expr(io::IOContext{IOBuffer}, node::JuliaSyntax.TreeNode{TypedSyntax.TypedSyntaxData}, position::Int64, pre::String, pre2::String; type_annotations::Bool, iswarn::Bool, hide_type_stable::Bool, nd::Int64) (repeats 4 times)
    @ TypedSyntax ~/.julia/packages/TypedSyntax/LVzdW/src/show.jl:80
  [6] show_src_expr
    @ ~/.julia/packages/TypedSyntax/LVzdW/src/show.jl:66 [inlined]
  [7] printstyled(io::IOContext{IOBuffer}, rootnode::JuliaSyntax.TreeNode{TypedSyntax.TypedSyntaxData}; type_annotations::Bool, iswarn::Bool, hide_type_stable::Bool, with_linenumber::Bool, idxend::Int64)
    @ TypedSyntax ~/.julia/packages/TypedSyntax/LVzdW/src/show.jl:50
  [8] printstyled
    @ ~/.julia/packages/TypedSyntax/LVzdW/src/show.jl:32 [inlined]
  [9] cthulhu_typed(io::IOContext{IOBuffer}, debuginfo::Symbol, src::Core.CodeInfo, rt::Any, effects::Core.Compiler.Effects, mi::Core.MethodInstance; iswarn::Bool, hide_type_stable::Bool, optimize::Bool, pc2remarks::Nothing, pc2effects::Nothing, inline_cost::Bool, type_annotations::Bool, annotate_source::Bool, inlay_types_vscode::Bool, diagnostics_vscode::Bool, jump_always::Bool, interp::Cthulhu.CthulhuInterpreter)
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/codeview.jl:168
 [10] cthulhu_typed
    @ ~/.julia/packages/Cthulhu/9kV71/src/codeview.jl:123 [inlined]
 [11] #cthulhu_typed#58
    @ ~/.julia/packages/Cthulhu/9kV71/src/codeview.jl:121 [inlined]
 [12] (::Cthulhu.var"#96#103"{Cthulhu.CthulhuInterpreter, Cthulhu.DInfo.DebugInfo, Core.CodeInfo, Core.CodeInfo, Union, Core.MethodInstance, Bool, Bool, Nothing, Nothing, Bool, Bool})(lambda_io::IOContext{IOBuffer})
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:492
 [13] stringify(f::Any, context::IOContext{Base.TTY})
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/ui.jl:90
 [14] _descend(term::REPL.Terminals.TTYTerminal, interp::Cthulhu.CthulhuInterpreter, curs::Cthulhu.CthulhuCursor; override::Core.Compiler.InferenceResult, debuginfo::Cthulhu.DInfo.DebugInfo, optimize::Bool, interruptexc::Bool, iswarn::Bool, hide_type_stable::Bool, verbose::Nothing, remarks::Bool, with_effects::Bool, inline_cost::Bool, type_annotations::Bool, annotate_source::Bool, inlay_types_vscode::Bool, diagnostics_vscode::Bool, jump_always::Bool)
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:491
 [15] _descend(term::REPL.Terminals.TTYTerminal, interp::Cthulhu.CthulhuInterpreter, curs::Cthulhu.CthulhuCursor; override::Nothing, debuginfo::Symbol, optimize::Bool, interruptexc::Bool, iswarn::Bool, hide_type_stable::Bool, verbose::Nothing, remarks::Bool, with_effects::Bool, inline_cost::Bool, type_annotations::Bool, annotate_source::Bool, inlay_types_vscode::Bool, diagnostics_vscode::Bool, jump_always::Bool)
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:610
 [16] _descend(term::REPL.Terminals.TTYTerminal, interp::Cthulhu.CthulhuInterpreter, mi::Core.MethodInstance; kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:iswarn,), Tuple{Bool}}})
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:756
 [17] _descend(::REPL.Terminals.TTYTerminal, ::Any, ::Vararg{Any}; interp::Core.Compiler.NativeInterpreter, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:iswarn,), Tuple{Bool}}})
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:772
 [18] __descend_with_error_handling(args::Any; terminal::Any, kwargs::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:213
 [19] _descend_with_error_handling(f::Any, argtypes::Any; kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:iswarn,), Tuple{Bool}}})
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:202
 [20] descend_code_warntype(::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:191
 [21] descend_code_warntype(::Any, ::Any)
    @ Cthulhu ~/.julia/packages/Cthulhu/9kV71/src/Cthulhu.jl:191
 [22] top-level scope
    @ REPL[60]:1

(@v1.9) pkg> st Cthulhu
Status `~/.julia/environments/v1.9/Project.toml`
  [f68482b8] Cthulhu v2.9.3

(@v1.9) pkg> st -m TypedSyntax
Status `~/.julia/environments/v1.9/Manifest.toml`
  [d265eb64] TypedSyntax v1.2.3
@jishnub jishnub changed the title UndefVarError: T not defined UndefVarError: T not defined in extract_inner_type Sep 20, 2023
Zentrik added a commit to Zentrik/Cthulhu.jl that referenced this issue Sep 25, 2023
Fixes JuliaDebug#506 which was due to calling `extract_inner_type` with `Type{AbstractArray{var"#s91"<:Real, 1}}`. Uses suggestions from JuliaDebug#493, this also removes the specialisation compared to the current implementation.
vchuravy pushed a commit that referenced this issue Oct 12, 2023
Fixes #506 which was due to calling `extract_inner_type` with `Type{AbstractArray{var"#s91"<:Real, 1}}`. Uses suggestions from #493, this also removes the specialisation compared to the current implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant