Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Errors for instanceof operator #735

Closed
wants to merge 6 commits into from
Closed

Errors for instanceof operator #735

wants to merge 6 commits into from

Conversation

hermanventer
Copy link
Contributor

Now give error messages for instanceof operators when the right operand is too abstract.

@NTillmann
Copy link
Contributor

As this change sits on top of, but also includes, previously approved pull requests, it's difficult for me to see what's new. Can you merge the other pull requests and rebase this one on top of them?

@hermanventer
Copy link
Contributor Author

My pull requests always involve only the last commit.

@@ -74,7 +74,7 @@ export function getPureBinaryOperationResultType(
} else if (op === ">>>" || op === "<<" || op === ">>" || op === "&" || op === "|" || op === "^" ||
op === "**" || op === "%" || op === "/" || op === "*" || op === "-") {
return reportErrorIfNotPure(IsToNumberPure, NumberValue);
} else if (op === "in") {
} else if (op === "in" || op === "instanceof") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are plain function values simple? Are bound function values simple? If so, I think the code below would have to peek into .$BoundTargetFunction to figure out if this operation is safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll make the isSimple check safer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turns out that it is perfectly safe already. Far too safe, in fact. But making a better alternative to isSimple is best left to a later pull request.

@facebook-github-bot
Copy link

@hermanventer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@hermanventer hermanventer deleted the absinstanceof branch June 20, 2017 02:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants