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