Skip to content

Infer rest type without using assignContextualParameterTypes - #49740

Merged
Jake Bailey (jakebailey) merged 4 commits into
microsoft:mainfrom
jakebailey:fix-49383
Jul 6, 2022
Merged

Infer rest type without using assignContextualParameterTypes#49740
Jake Bailey (jakebailey) merged 4 commits into
microsoft:mainfrom
jakebailey:fix-49383

Conversation

@jakebailey

@jakebailey Jake Bailey (jakebailey) commented Jun 29, 2022

Copy link
Copy Markdown
Member

Fixes #49383

It was suspicious to me that assignContextualParameterTypes was being called here when inferFromAnnotatedParameters's only caller will always immediately call assignContextualParameterTypes again, which means you're pretty much guaranteed to hit the debug assert for a duplicate assignParameterType.

It looks like all that this was doing was assigning the rest type to the signature, then picking it back out again to pass to inferTypes, so just don't do that, instead obtaining the type directly. The caller will call assignContextualParameterTypes to eventually assign it, and the code surrounding this manages just fine without assignContextualParameterTypes.

Move the code entirely out of inferFromAnnotatedParameters and don't call assignContextualParameterTypes; the code that was added in #30114 has nothing to do with annotated parameters.

Comment thread tests/baselines/reference/getParameterNameAtPosition.types Outdated
@jakebailey

Copy link
Copy Markdown
Member Author

Huh, fails in ci for some reason

@jakebailey

Copy link
Copy Markdown
Member Author

Oh, because it's wrong and I didn't notice because I was debugging one test and forgot to run the whole suite :(

@jakebailey
Jake Bailey (jakebailey) marked this pull request as draft June 30, 2022 02:14
@jakebailey
Jake Bailey (jakebailey) marked this pull request as ready for review June 30, 2022 02:26
@jakebailey

Copy link
Copy Markdown
Member Author

Okay, I think it's better now; all of the other changes disappeared.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug Failure. Parameter symbol already has a cached type which differs from newly assigned type.

4 participants