Skip to content

Commit d732903

Browse files
authored
add a test for #41096 (#41556)
1 parent 944fcfc commit d732903

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/compiler/codegen.jl

+32
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,35 @@ f41438(y) = y[].x
597597
# issue #41157
598598
f41157(a, b) = a[1] = b[1]
599599
@test_throws BoundsError f41157(Tuple{Int}[], Tuple{Union{}}[])
600+
601+
# issue #41096
602+
struct Modulate41096{M<:Union{Function, Val{true}, Val{false}}, id}
603+
modulate::M
604+
Modulate41096(id::Symbol, modulate::Function) = new{typeof(modulate), id}(modulate)
605+
Modulate41096(id::Symbol, modulate::Bool=true) = new{Val{modulate}, id}(modulate|>Val)
606+
end
607+
@inline ismodulatable41096(modulate::Modulate41096) = ismodulatable41096(typeof(modulate))
608+
@inline ismodulatable41096(::Type{<:Modulate41096{Val{B}}}) where B = B
609+
@inline ismodulatable41096(::Type{<:Modulate41096{<:Function}}) = true
610+
611+
mutable struct Term41096{I, M<:Modulate41096}
612+
modulate::M
613+
Term41096{I}(modulate::Modulate41096) where I = new{I, typeof(modulate)}(modulate)
614+
end
615+
@inline ismodulatable41096(term::Term41096) = ismodulatable41096(typeof(term))
616+
@inline ismodulatable41096(::Type{<:Term41096{I, M} where I}) where M = ismodulatable41096(M)
617+
618+
function newexpand41096(gen, name::Symbol)
619+
flag = ismodulatable41096(getfield(gen, name))
620+
if flag
621+
return true
622+
else
623+
return false
624+
end
625+
end
626+
627+
t41096 = Term41096{:t}(Modulate41096(:t, false))
628+
μ41096 = Term41096{:μ}(Modulate41096(, false))
629+
U41096 = Term41096{:U}(Modulate41096(:U, false))
630+
631+
@test !newexpand41096((t=t41096, μ=μ41096, U=U41096), :U)

0 commit comments

Comments
 (0)