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

Fix inference of one-arg return_type method #49407

Merged
merged 3 commits into from
Apr 21, 2023
Merged

Fix inference of one-arg return_type method #49407

merged 3 commits into from
Apr 21, 2023

Conversation

Keno
Copy link
Member

@Keno Keno commented Apr 18, 2023

Core.Compiler.return_type has two methods:

  • return_type(f, args::Type{<:Tuple})
  • return_type(args::Type{<:Tuple})

Our inference code was only catching the first one. Expand it to support both.

`Core.Compiler.return_type` has two methods:
 - return_type(f, args::Type{<:Tuple})
 - return_type(args::Type{<:Tuple})

Our inference code was only catching the first one.
Expand it to support both.
end
argtypes_vec = Any[aft, af_argtype.parameters...]
else
argtypes_vec = Any[af_argtype.parameters...]
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should perform a check that is equivalent to (f, tt::DataType) case here?

Suggested change
argtypes_vec = Any[af_argtype.parameters...]
aft = af_argtype.parameters[1]
if (!(isType(aft) && !has_free_typevars(aft)) &&
!(isconcretetype(aft) && !(aft <: Builtin)))
return UNKNOWN
end
argtypes_vec = Any[af_argtype.parameters...]

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it's required. That check in the other branch is just to avoid accidentally catching the interp method.

test/compiler/inference.jl Outdated Show resolved Hide resolved
@Keno Keno merged commit 186634e into master Apr 21, 2023
@Keno Keno deleted the kf/oneargrettype branch April 21, 2023 01:12
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