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

#6 Number subtypes #28

Merged
merged 6 commits into from
Feb 23, 2019
Merged

#6 Number subtypes #28

merged 6 commits into from
Feb 23, 2019

Conversation

mraak
Copy link
Collaborator

@mraak mraak commented Feb 22, 2019

No description provided.

lib/checker.js Show resolved Hide resolved
lib/checker.js Outdated Show resolved Hide resolved
* #8 Allowing assignement to any, handling any as argument. Added line and column display to messages.

* #8 indentation

* checker: fixing bug where 'any' and 'undef' were confused (#26)
@mraak mraak requested a review from getify February 22, 2019 20:26
Copy link
Owner

@getify getify left a comment

Choose a reason for hiding this comment

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

LGTM other than those two tweaks I just commented.

lib/checker.js Outdated Show resolved Hide resolved
lib/checker.js Outdated Show resolved Hide resolved
@mraak mraak requested a review from getify February 23, 2019 07:41
Copy link
Owner

@getify getify left a comment

Choose a reason for hiding this comment

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

Also, line 372 needs to change to the isAssignmentAllowed(..) check.

@@ -1457,7 +1449,7 @@ function handleCallExpression(scope,callExprNode,isSelfRecursivePTC = false) {
let argSignature = typeSignatures.get(argType);

if (paramTypeID != "unknown") {
if (!typesMatch(argType,paramType)) {
if (!typesMatch(argType,paramType) && paramTypeID != "any") {
Copy link
Owner

Choose a reason for hiding this comment

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

I think this line can just reference the isAssignmentAllowed(..) check now.

Copy link
Collaborator Author

@mraak mraak Feb 23, 2019

Choose a reason for hiding this comment

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

You think this and line 372 are safe to change to use isAssignmentAllowed? I haven't tested for this. Also, these locations don't actually deal with assignments so maybe a more generic function name would be appropriate. Maybe to change isAssignmentAllowed to typesCompatible, that way it would function similar to typesMatch but more permissive.

@@ -1672,19 +1671,20 @@ function isAssignmentAllowed(sourceType, targetType){
}

let matches = {
any: recognizedTypeIDs,
Copy link
Owner

Choose a reason for hiding this comment

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

Nice... this is a great way to handle it. Thanks!

@mraak mraak merged commit f3f1522 into master Feb 23, 2019
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