Skip to content

Commit

Permalink
fix uninferable type
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger-luo committed Apr 5, 2021
1 parent 807c6bf commit 276b0d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ function uninferrable_typevars(def::Union{JLStruct, JLKwStruct})

uninferrable = []
for T in typevars
T in field_types || push!(uninferrable, T)
any(map(f->has_symbol(f, T), field_types)) || push!(uninferrable, T)
end
return uninferrable
end
Expand Down
14 changes: 14 additions & 0 deletions test/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ using Expronicon
@test is_fn(:(x -> 2x))
end

@testset "uninferrable_typevars" begin
def = @expr JLKwStruct struct Inferable1{T}
x::Constaint{T, <(2)}
end

@test isempty(uninferrable_typevars(def))

def = @expr JLKwStruct struct Inferable2{T}
x::Constaint{Float64, <(2)}
end

@test uninferrable_typevars(def) == [:T]
end

@testset "is_kw_fn" begin
@test is_kw_fn(:(
function foo(x::Int; kw=1)
Expand Down

0 comments on commit 276b0d5

Please sign in to comment.