Skip to content

Commit

Permalink
Support Assign Exponent in NTI.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163361548
  • Loading branch information
EatingW authored and brad4d committed Jul 28, 2017
1 parent 861c32b commit b6c9eed
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/com/google/javascript/jscomp/NewTypeInference.java
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,7 @@ private EnvTypePair analyzeExprFwd(
case ASSIGN_MUL:
case ASSIGN_DIV:
case ASSIGN_MOD:
case ASSIGN_EXPONENT:
resultPair = analyzeAssignNumericOpFwd(expr, inEnv);
break;
case SHEQ:
Expand Down Expand Up @@ -3614,6 +3615,7 @@ private EnvTypePair analyzeExprBwd(
case ASSIGN_MUL:
case ASSIGN_DIV:
case ASSIGN_MOD:
case ASSIGN_EXPONENT:
return analyzeAssignNumericOpBwd(expr, outEnv);
case GETPROP:
{
Expand Down
29 changes: 29 additions & 0 deletions test/com/google/javascript/jscomp/NewTypeInferenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13816,6 +13816,35 @@ public void testExponent() {
"var /** number */ n = 1 ** NaN;");
}

public void testAssignExponent() {
typeCheck(LINE_JOINER.join(
"function f(/** number */ x) {",
" x **= 1;",
"}"));

typeCheck(LINE_JOINER.join(
"function f(/** * */ x) {",
" x **= 1;",
"}"),
NewTypeInference.INVALID_OPERAND_TYPE);

typeCheck(LINE_JOINER.join(
"function f(/** number */ x) {",
" x **= '';",
"}"),
NewTypeInference.INVALID_OPERAND_TYPE);

typeCheck(LINE_JOINER.join(
"function f(/** !Number */ x) {",
" x **= 1;",
"}"));

typeCheck(LINE_JOINER.join(
"function f(/** number */ x) {",
" x **= NaN;",
"}"));
}

public void testUndefinedFunctionCtorNoCrash() {
typeCheckCustomExterns("", "function f(x) {}",
GlobalTypeInfoCollector.FUNCTION_CONSTRUCTOR_NOT_DEFINED);
Expand Down

0 comments on commit b6c9eed

Please sign in to comment.