Skip to content

fix(rosetta): correctly detect arguments typed as any#3043

Merged
mergify[bot] merged 1 commit intomainfrom
huijbers/detect-any
Oct 8, 2021
Merged

fix(rosetta): correctly detect arguments typed as any#3043
mergify[bot] merged 1 commit intomainfrom
huijbers/detect-any

Conversation

@rix0rrr
Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr commented Oct 7, 2021

Try and resolve the containing function call. If it resolves, we
know the any the typechecker is giving us is actually intended to
be an any.

If the containing call does not resolve, we'll treat it as an unknown
type of an uncompiling sample, and assume there's a struct there.

Fixes #3029.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Try and resolve the containing function call. If it resolves, we
know the `any` the typechecker is giving us is actually intended to
be an `any`.

If the containing call does not resolve, we'll treat it as an unknown
type of an uncompiling sample, and assume there's a struct there.

Fixes #3029.
@rix0rrr rix0rrr requested a review from a team October 7, 2021 14:33
@rix0rrr rix0rrr self-assigned this Oct 7, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 7, 2021
@nija-at nija-at added the pr/do-not-merge This PR should not be merged at this time. label Oct 7, 2021
// Search for the function's declaration and only if we can't find it,
// the type is actually unknown (otherwise it's a literal 'any').
const call = findEnclosingCallExpression(node);
const signature = call ? context.typeChecker.getResolvedSignature(call) : undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I like to do this as

Suggested change
const signature = call ? context.typeChecker.getResolvedSignature(call) : undefined;
const signature = call && context.typeChecker.getResolvedSignature(call);

@rix0rrr rix0rrr removed the pr/do-not-merge This PR should not be merged at this time. label Oct 8, 2021
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Oct 8, 2021

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Oct 8, 2021
@mergify mergify bot merged commit 3d2ba15 into main Oct 8, 2021
@mergify mergify bot deleted the huijbers/detect-any branch October 8, 2021 08:10
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Oct 8, 2021

Merging (with squash)...

@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(rosetta) type inference is not sufficiently narrowed causing incorrect Python translations

2 participants