https://github.com/JuliaLang/julia
Revision c5e462137298a6876ca8bd0939f6e5ff79996d14 authored by Shuhei Kadowaki on 19 July 2023, 05:01:21 UTC, committed by GitHub on 19 July 2023, 05:01:21 UTC
At present, in very rare cases, `PartialStruct` used for const-prop'
might have type information that's less strict than type information
that can be derived from the method's type signature, e.g.:
```julia
Base.@constprop :aggressive function refine_partial_struct((a, b)::Tuple{String,Int})
    if iszero(b)
        println("b=0") # to prevent semi-concrete eval
        return nothing
    else
        return a
    end
end
@test Base.return_types((AbstractString,)) do s
    refine_partial_struct((s, 42))
end |> only === String
```

This commit enhances the accuracy of const-prop' by propagating `tmeet`
of `PartialStruct` and the declared type in such situations.
1 parent 0bf560a
Raw File
Tip revision: c5e462137298a6876ca8bd0939f6e5ff79996d14 authored by Shuhei Kadowaki on 19 July 2023, 05:01:21 UTC
inference: refine `PartialStruct` with declared method signature (#50590)
Tip revision: c5e4621
CITATION.cff
cff-version: 1.2.0
message: "Cite this paper whenever you use Julia"
authors:
- family-names: "Bezanson"
  given-names: "Jeff"
- family-names: "Edelman"
  given-names: "Alan"
- family-names: "Karpinski"
  given-names: "Stefan"
- family-names: "Shah"
  given-names: "Viral B."
title: "Julia: A fresh approach to numerical computing"
version: "v1"
license: "MIT"
doi: "10.1137/141000671"
date-released: 2017-02-07
url: "https://julialang.org"
preferred-citation:
  authors:
    - family-names: "Bezanson"
      given-names: "Jeff"
    - family-names: "Edelman"
      given-names: "Alan"
    - family-names: "Karpinski"
      given-names: "Stefan"
    - family-names: "Shah"
      given-names: "Viral B."
  doi: "10.1137/141000671"
  journal: "SIAM Review"
  month: 9
  start: 65
  end: 98
  pages: 33
  title: "Julia: A fresh approach to numerical computing"
  type: article
  volume: 59
  issue: 1
  year: 2017
  publisher:
    name: "SIAM"
back to top