Skip to content

Commit

Permalink
add a test for #41096 (#41556)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Jul 13, 2021
1 parent 944fcfc commit d732903
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -597,3 +597,35 @@ f41438(y) = y[].x
# issue #41157
f41157(a, b) = a[1] = b[1]
@test_throws BoundsError f41157(Tuple{Int}[], Tuple{Union{}}[])

# issue #41096
struct Modulate41096{M<:Union{Function, Val{true}, Val{false}}, id}
modulate::M
Modulate41096(id::Symbol, modulate::Function) = new{typeof(modulate), id}(modulate)
Modulate41096(id::Symbol, modulate::Bool=true) = new{Val{modulate}, id}(modulate|>Val)
end
@inline ismodulatable41096(modulate::Modulate41096) = ismodulatable41096(typeof(modulate))
@inline ismodulatable41096(::Type{<:Modulate41096{Val{B}}}) where B = B
@inline ismodulatable41096(::Type{<:Modulate41096{<:Function}}) = true

mutable struct Term41096{I, M<:Modulate41096}
modulate::M
Term41096{I}(modulate::Modulate41096) where I = new{I, typeof(modulate)}(modulate)
end
@inline ismodulatable41096(term::Term41096) = ismodulatable41096(typeof(term))
@inline ismodulatable41096(::Type{<:Term41096{I, M} where I}) where M = ismodulatable41096(M)

function newexpand41096(gen, name::Symbol)
flag = ismodulatable41096(getfield(gen, name))
if flag
return true
else
return false
end
end

t41096 = Term41096{:t}(Modulate41096(:t, false))
μ41096 = Term41096{:μ}(Modulate41096(, false))
U41096 = Term41096{:U}(Modulate41096(:U, false))

@test !newexpand41096((t=t41096, μ=μ41096, U=U41096), :U)

0 comments on commit d732903

Please sign in to comment.