Test and workaround inference bugs

This commit is contained in:
Amjad Masad
2015-12-18 03:15:27 -08:00
parent 31032ee7ad
commit 57b2ccdb66
4 changed files with 67 additions and 3 deletions

View File

@@ -48,6 +48,14 @@ function getTypeAnnotationBindingConstantViolations(path, name) {
if (constantViolations.length) {
// pick one constant from each scope which will represent the last possible
// control flow path that it could've taken/been
/* This code is broken for the following problems:
* It thinks that assignments can only happen in scopes.
* What about conditionals, if statements without block,
* or guarded assignments.
* It also checks to see if one of the assignments is in the
* same scope and uses that as the only "violation". However,
* the binding is returned by `getConstantViolationsBefore` so we for
* sure always going to return that as the only "violation".
let rawConstantViolations = constantViolations.reverse();
let visitedScopes = [];
constantViolations = [];
@@ -62,7 +70,7 @@ function getTypeAnnotationBindingConstantViolations(path, name) {
constantViolations = [violation];
break;
}
}
}*/
// add back on function constant violations since we can't track calls
constantViolations = constantViolations.concat(functionConstantViolations);