@@ -3,20 +3,46 @@ using Revise; include(joinpath("test", "test_depth_limited_type_printing.jl"))
33=#
44import Cthulhu
55
6+ using Cthulhu
7+ Cthulhu. CONFIG. type_depth_limit = 2
8+
69Base. @kwdef struct Nested{A,B}
710 num:: Int = 1
811end
9- struct F49231{a,b,c,d,e,f,g}
10- num:: g
11- end ;
1212bar (x) = rand () > 0.5 ? x : Any[0 ][1 ]
1313mysum (x) = sum (y-> bar (x. num), 1 : 5 ; init= 0 )
1414nest_val (na, nb, :: Val{1} ) = Nested {na, nb} ()
1515nest_val (na, nb, :: Val{n} ) where {n} = nest_val (Nested{na, nb}, Nested{na, nb}, Val (n- 1 ))
1616nest_val (na, nb, n:: Int ) = nest_val (na, nb, Val (n))
1717nest_val (n) = nest_val (1 , 1 , n)
18+ const NV = nest_val (5 )
19+
20+ # f = nest_val(5)
21+ # a = Any[f];
22+ # mysum(a[1]) # make sure it runs
23+ # Cthulhu.@descend mysum(a[1]) # navigate to sum -> sum, and Nested will be there
24+ using Test
25+ include (" setup.jl" )
26+ @testset " hide type-stable statements" begin
27+ let # optimize code
28+ # f = nest_val(5)
29+ # a = Any[f];
30+ # mysum(a[1]) # make sure it runs
31+ # Cthulhu.@descend mysum(a[1]) # navigate to sum -> sum, and Nested will be there
32+ (; src, infos, mi, rt, exct, effects, slottypes) = @eval Module () begin
33+ $ cthulhu_info ($ mysum, ($ (typeof (NV)),))
34+ end ;
35+ function prints (; kwargs... )
36+ io = IOBuffer ()
37+ ioc = IOContext (io, :maxtypedepth => Cthulhu. CONFIG. type_depth_limit)
38+ Cthulhu. cthulhu_typed (ioc, :none , src, rt, exct, effects, mi; kwargs... )
39+ return String (take! (io))
40+ end ;
1841
19- f = nest_val (5 )
20- a = Any[f];
21- mysum (a[1 ]) # make sure it runs
22- Cthulhu. @descend mysum (a[1 ]) # navigate to sum -> sum, and F49231 will be there
42+ let # by default, should print every statement
43+ s = prints ()
44+ println (s)
45+ # @test occursin("::Nested{Nested{…}, Nested{…}}", s)
46+ end
47+ end
48+ end
0 commit comments