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

@descend first takes a long time, then when selecting a function, throws TypeError: in typeassert, expected Vector{Any}, got a value of type Nothing #598

Open
fingolfin opened this issue Sep 18, 2024 · 0 comments
Labels
bug Something isn't working TypedSyntax An issue or pull request relating to the TypedSyntax.jl subpackage

Comments

@fingolfin
Copy link
Contributor

I was trying to use Cthulhu on some code which, well, goes down deep and does some complex stuff. JET also took like forever on the code (I didn't measure it, but let's say 10 minutes upward for @report_opt test_elliptic). Cthulhu also took minutes. Then it finally showed a prompt, offering me to functions calls to descend into. I selected the second one, a function weierstrass_contraction, but unfortunately this triggered a type assertion.

Stack trace:

julia> @descend test_elliptic()
test_elliptic() @ Main REPL[8]:1
1 test_elliptic()::AbsCoveredSchemeMorphism = weierstrass_contraction(elliptic_surface(E::Any, 2, mwl_basis::Any)::EllipticSurface{_A, BaseField} where {_A<:Field, BaseField<:(AbstractAlgebra.Generic.FracFieldElem{<:PolyRingElem{<:FieldElem}})})
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
   elliptic_surface(E::Any, 2, mwl_basis::Any)
 • weierstrass_contraction(elliptic_surface(E::Any, 2, mwl_basis::Any)::EllipticSurface{_A, BaseField} …
   ↩
ERROR: TypeError: in typeassert, expected Vector{Any}, got a value of type Nothing
Stacktrace:
  [1] gettyp
    @ ~/.julia/packages/TypedSyntax/TMfzf/src/node.jl:291 [inlined]
  [2] addchildren!(tparent::JuliaSyntax.TreeNode{…}, parent::JuliaSyntax.SyntaxNode, src::Core.CodeInfo, node2ssa::IdDict{…}, symtyps::IdDict{…}, mappings::Vector{…})
    @ TypedSyntax ~/.julia/packages/TypedSyntax/TMfzf/src/node.jl:97
  [3] addchildren!(tparent::JuliaSyntax.TreeNode{…}, parent::JuliaSyntax.SyntaxNode, src::Core.CodeInfo, node2ssa::IdDict{…}, symtyps::IdDict{…}, mappings::Vector{…}) (repeats 2 times)
    @ TypedSyntax ~/.julia/packages/TypedSyntax/TMfzf/src/node.jl:102
  [4] JuliaSyntax.TreeNode{…}(rootnode::JuliaSyntax.SyntaxNode, src::Core.CodeInfo, mappings::Vector{…}, symtyps::IdDict{…})
    @ TypedSyntax ~/.julia/packages/TypedSyntax/TMfzf/src/node.jl:81
  [5] tsn_and_mappings(mi::Core.MethodInstance, src::Core.CodeInfo, rt::Any, sourcetext::SubString{…}, lineno::Int32; warn::Bool, strip_macros::Bool, kwargs::@Kwargs{})
    @ TypedSyntax ~/.julia/packages/TypedSyntax/TMfzf/src/node.jl:55
  [6] tsn_and_mappings(mi::Core.MethodInstance, src::Core.CodeInfo, rt::Any; warn::Bool, strip_macros::Bool, kwargs::@Kwargs{})
    @ TypedSyntax ~/.julia/packages/TypedSyntax/TMfzf/src/node.jl:39
  [7] get_typed_sourcetext(mi::Core.MethodInstance, src::Core.CodeInfo, rt::Any; warn::Bool)
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/reflection.jl:361
  [8] find_callsites(interp::Cthulhu.CthulhuInterpreter, CI::Core.CodeInfo, stmt_infos::Vector{…}, mi::Core.MethodInstance, slottypes::Vector{…}, optimize::Bool, annotate_source::Bool, pc2excts::Nothing)
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/reflection.jl:37
  [9]
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/Cthulhu.jl:559
 [10]
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/Cthulhu.jl:710
 [11] _descend(term::REPL.Terminals.TTYTerminal, interp::Cthulhu.CthulhuInterpreter, mi::Core.MethodInstance; kwargs::@Kwargs{…})
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/Cthulhu.jl:863
 [12] _descend(term::REPL.Terminals.TTYTerminal, args::Any; interp::Core.Compiler.NativeInterpreter, kwargs::@Kwargs{…})
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/Cthulhu.jl:879
 [13] __descend_with_error_handling(args::Any; terminal::Any, kwargs...)
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/Cthulhu.jl:263
 [14] _descend_with_error_handling(f::Any, argtypes::Any; kwargs::@Kwargs{iswarn::Bool})
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/Cthulhu.jl:252
 [15] descend(::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Cthulhu ~/.julia/packages/Cthulhu/7Nd1o/src/Cthulhu.jl:306
 [16] top-level scope
    @ REPL[10]:1
Some type information was truncated. Use `show(err)` to see complete types.

Code for reproducing (sorry, it's big; I'll try to cut it down (it's taken from the Oscar.jl test suite, and I am looking into tuning that code. It is likely premature to run JET and Cthulhu on it, but I wanted to see what would happen. I didn't expect a type assertion. Maybe the location already gives you an idea what is going on)

using Oscar, Cthulhu

k = GF(29)
# The generic fiber of the elliptic fibration
# as an elliptic curve over k(t)
kt, t = polynomial_ring(k, :t)
kP1 = fraction_field(kt)
t = gen(kP1)
E = elliptic_curve(kP1, [3*t^8 + 10*t^7 + 6*t^6 + 17*t^5 + 25*t^4 + 4*t^3 + 23*t^2 + 9*t + 14, 5*t^12 + 25*t^11 + 2*t^10 + 28*t^9 + 28*t^8 + 19*t^7 + 3*t^6 + 17*t^5 + 19*t^4 + 12*t^3 + 25*t^2 + 12*t + 6])
# A basis for the Mordell-Weil group of E
mwl_basis = [E(collect(i)) for i in [
(12*t^4 + 21*t^3 + 5*t^2 + 12*t + 18, 23*t^5 + 7*t^4 + 22*t^3 + 13*t^2),
(12*t^4 + 20*t^3 + 22*t^2 + 27*t + 18, 15*t^4 + 12*t^3 + 12*t),
(12*t^4 + 20*t^3 + 27*t^2 + 11*t + 18, -(16*t^4 + 24*t^3 + 3*t^2 + 24*t)),
(4*t^4 + 5*t^3 + 5*t^2 + 6*t + 13,  9*t^6 + 21*t^5 + 17*t^4 + 12*t^2 + 3*t + 6)]]

test_elliptic() = weierstrass_contraction(elliptic_surface(E, 2, mwl_basis))
julia> pkgversion(Cthulhu)
v"2.15.0"

julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
@simeonschaub simeonschaub added bug Something isn't working TypedSyntax An issue or pull request relating to the TypedSyntax.jl subpackage labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working TypedSyntax An issue or pull request relating to the TypedSyntax.jl subpackage
Projects
None yet
Development

No branches or pull requests

2 participants