Skip to content

Fix inference of one-arg return_type method#49407

Merged
Keno merged 3 commits intomasterfrom
kf/oneargrettype
Apr 21, 2023
Merged

Fix inference of one-arg return_type method#49407
Keno merged 3 commits intomasterfrom
kf/oneargrettype

Conversation

@Keno
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@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