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

Use depth-limited type printing, from Julia 1.10 #566

Open
charleskawczynski opened this issue Apr 19, 2024 · 13 comments · May be fixed by #568
Open

Use depth-limited type printing, from Julia 1.10 #566

charleskawczynski opened this issue Apr 19, 2024 · 13 comments · May be fixed by #568
Labels
enhancement New feature or request

Comments

@charleskawczynski
Copy link

This is my analog request of aviatesk/JET.jl#616

@charleskawczynski
Copy link
Author

🏊🏻‍♂️ in types over here...

Screen Shot 2024-04-19 at 11 14 35 AM

@Zentrik
Copy link
Collaborator

Zentrik commented Apr 25, 2024

I think someone would just need to truncate this and add some option to enable/disable it,

T_str = string(T)

@charleskawczynski
Copy link
Author

I have a branch where I'm experimenting with depth-limited type printing, and that unfortunately doesn't seem to be working

@Zentrik
Copy link
Collaborator

Zentrik commented Apr 25, 2024

Are you sure you're using your custom TypedSyntax, it's its own package. Just loading your branch of Cthulhu won't work I think.

@charleskawczynski
Copy link
Author

Yeah, I did ] dev TypedSyntax from Cthulhu.jl/

@Zentrik
Copy link
Collaborator

Zentrik commented Apr 25, 2024

That's odd, I changed that line to T_str = string(T)[1:2] and it works

julia> @descend sin(42.)
sin(x::T) where T<:Union{Float32, Float64} @ Base.Math C:\Users\gag\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\base\special\trig.jl:29       
29 function (sin(x::Fl::T) where T<:Union{Float32, Float64})::Fl
30     absx::Fl = abs(x::Fl)::Fl
31     if (absx::Fl < (T::Ty(pi::Ir)::Fl/4)::Fl)::Bo #|x| ~<= pi/4, no need for reduction
32         if (absx::Fl < sqrt(eps(T::Ty)::Fl)::Fl)::Bo
33             return x::Fl
34         end
35         return sin_kernel(x::Fl)::Fl
36     elseif isnan(x::Fl)::Bo
37         return x::Fl
38     elseif isinf(x::Fl)::Bo
39         sin_domain_error(x::Fl)
40     end
41     n::In, y::Ba = rem_pio2_kernel(x::Fl)::Tu::Ba
42     n::In = (n::In&3)::In
43     if (n::In == 0)::Bo
44         return sin_kernel(y::Ba)::Fl
45     elseif (n::In == 1)::Bo
46         return cos_kernel(y::Ba)::Fl
47     elseif (n::In == 2)::Bo
48         return -(sin_kernel(y::Ba)::Fl)::Fl
49     else
50         return -(cos_kernel(y::Ba)::Fl)::Fl
51     end
52 end
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, [v]scode: inlay types, [V]scode: diagnostics.
Show: [S]ource code, [A]ST, [T]yped code, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
 • abs(x::Fl)
   T::Ty(pi::Ir)
    T::Ty(pi::Ir)::Fl/4
    absx::Fl < (T::Ty(pi::Ir)::Fl/4)::Fl
   eps(T::Ty)
   sqrt(eps(T::Ty)::Fl)
    absx::Fl < sqrt(eps(T::Ty)::Fl)::Fl
   sin_kernel(x::Fl)
   isnan(x::Fl)
v  isinf(x::Fl)

@charleskawczynski
Copy link
Author

Huh, interesting, I'll try again

@charleskawczynski
Copy link
Author

charleskawczynski commented Apr 25, 2024

Hmm, I can't even error inside that function. Can you put an error in there and show the stack trace?

@charleskawczynski
Copy link
Author

I might have to Cthulhu Cthulhu 😵‍💫

@charleskawczynski charleskawczynski linked a pull request Apr 25, 2024 that will close this issue
@Zentrik
Copy link
Collaborator

Zentrik commented Apr 25, 2024

We call the printstyled in the show.jl file linked here, https://github.com/JuliaDebug/Cthulhu.jl/blob/master/src/codeview.jl#L152

@Zentrik
Copy link
Collaborator

Zentrik commented Apr 25, 2024

Also, we pass an iocontext object to printstyled so perhaps just add the type limit to that like we do at https://github.com/JuliaDebug/Cthulhu.jl/blob/master/TypedSyntax/src/show.jl#L117-118

@charleskawczynski
Copy link
Author

Ah, wow, when I did ]dev TypedSyntax from Cthulhu.jl/, it picked up TypedSyntax in a different Cthulhu.jl directory!

@charleskawczynski
Copy link
Author

Looks like its working now

@simeonschaub simeonschaub added the enhancement New feature or request label Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants