Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve inferrability of [region...] #180

Merged
merged 1 commit into from
Jan 22, 2021
Merged

Conversation

timholy
Copy link
Member

@timholy timholy commented Jan 22, 2021

This fixes the following problem:

julia> docat(v) = [v...]
docat (generic function with 1 method)

julia> code_typed(docat, (UnitRange{Int},))
1-element Vector{Any}:
 CodeInfo(
1%1 = Core._apply_iterate(Base.iterate, Base.vect, v)::Vector{_A} where _A
└──      return %1
) => Vector{_A} where _A

julia> code_typed(docat, (Vector{Int},))
1-element Vector{Any}:
 CodeInfo(
1%1 = Core._apply_iterate(Base.iterate, Base.vect, v)::Union{Vector{Any}, Vector{Int64}}
└──      return %1
) => Union{Vector{Any}, Vector{Int64}}

Essentially, because region... is implemented via the parser,
it relies on the call vect(args...) and the risk is that args
might be empty, which causes it to return Vector{Any}.

This fixes the following problem:

```julia
julia> docat(v) = [v...]
docat (generic function with 1 method)

julia> code_typed(docat, (UnitRange{Int},))
1-element Vector{Any}:
 CodeInfo(
1 ─ %1 = Core._apply_iterate(Base.iterate, Base.vect, v)::Vector{_A} where _A
└──      return %1
) => Vector{_A} where _A

julia> code_typed(docat, (Vector{Int},))
1-element Vector{Any}:
 CodeInfo(
1 ─ %1 = Core._apply_iterate(Base.iterate, Base.vect, v)::Union{Vector{Any}, Vector{Int64}}
└──      return %1
) => Union{Vector{Any}, Vector{Int64}}
```

Essentially, because `region...` is implemented via the parser,
it relies on the call `vect(args...)` and the risk is that `args`
might be empty, which causes it to return `Vector{Any}`.
@codecov
Copy link

codecov bot commented Jan 22, 2021

Codecov Report

Merging #180 (18829ab) into master (59f38c6) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #180   +/-   ##
=======================================
  Coverage   67.16%   67.16%           
=======================================
  Files           3        3           
  Lines         402      402           
=======================================
  Hits          270      270           
  Misses        132      132           
Impacted Files Coverage Δ
src/fft.jl 63.66% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59f38c6...18829ab. Read the comment docs.

@timholy timholy merged commit d04bda9 into master Jan 22, 2021
@timholy timholy deleted the teh/infer_cat_region branch January 22, 2021 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants