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

Fixes some inference issues #39606

Merged
merged 4 commits into from
Feb 16, 2021
Merged

Fixes some inference issues #39606

merged 4 commits into from
Feb 16, 2021

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Feb 10, 2021

In review of #39512, I noticed some other issues in Core.Inference, which I address here.

Comment on lines -223 to -224
bail_out_statement(interp::AbstractInterpreter, @nospecialize(t), sv) = t === Bottom
bail_out_local(interp::AbstractInterpreter, @nospecialize(t), sv) = t === Bottom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the response to this change here.

This logic is present to avoid asking ill-posed questions after we
discover the dataflow is terminated, similar to how we'd remove the code
after throw or a constant branch.

Refs: #39439 (comment)
This only would matter if we transition a call from T -> Union{}, which
is unlikely to happen, and even less likely to be observed, but it is
more correct this way.
Previously, we might accidentally leave behind content in the fields
that should not be there. For example:

```
julia> code_typed(() -> (TypeVar(:x),), (), optimize=false)
1-element Vector{Any}:
 CodeInfo(
    @ REPL[1]:1 within `#3'
1 ─ %1 = Main.TypeVar(:x)::Core.Compiler.PartialTypeVar(x, true, true)
│   %2 = Core.tuple(%1)::Core.PartialStruct(Tuple{TypeVar}, Any[Core.Compiler.PartialTypeVar(x, true, true)])
└──      return %2
) => Tuple{TypeVar}

julia> ans[1][1].rettype
Core.PartialStruct(Tuple{TypeVar}, Any[Core.Compiler.PartialTypeVar(x, true, true)])
```
@vtjnash vtjnash force-pushed the jn/inference-widenreturn branch from 7c8114c to 55eca20 Compare February 16, 2021 16:54
@vtjnash vtjnash merged commit bbdf1cf into master Feb 16, 2021
@vtjnash vtjnash deleted the jn/inference-widenreturn branch February 16, 2021 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants