Permalink
Browse files

in weak mode; don't force `v += 1` into String just because v == Any

similar thing for compare, any > 1 should not trip, that just adds noise
  • Loading branch information...
onnlucky committed Nov 2, 2015
1 parent a6b8430 commit 81b8822ff299267268244d979dd250e2722c86b6
Showing with 26 additions and 1 deletion.
  1. +5 −1 src/typing/flow_js.ml
  2. +7 −0 tests/opassign/.flowconfig
  3. +2 −0 tests/opassign/opassign.exp
  4. +12 −0 tests/opassign/opassign.js
View
@@ -3447,7 +3447,9 @@ and flow_addition cx trace reason l r u =
rec_flow cx trace (NumT.why reason, u)
| (_, _) ->
let fake_str = StrT.why reason in
let fake_str = if Context.is_weak cx
then MixedT.why reason
else StrT.why reason in
rec_flow cx trace (l, fake_str);
rec_flow cx trace (r, fake_str);
rec_flow cx trace (fake_str, u);
@@ -3464,6 +3466,8 @@ and flow_comparator cx trace reason l r =
else match (l, r) with
| (StrT _, StrT _) -> ()
| (_, _) when numeric l && numeric r -> ()
| (AnyT _, _) when Context.is_weak cx && numeric r -> ()
| (_, AnyT _) when Context.is_weak cx && numeric l -> ()
| (_, _) -> prerr_flow cx trace "Cannot be compared to" l r
(**
@@ -0,0 +1,7 @@
[ignore]
[include]
[libs]
[options]
@@ -0,0 +1,2 @@
Found 0 errors
View
@@ -0,0 +1,12 @@
/* @flow weak */
var n1 = 0
function f1() {
n1 += 1
}
var n2 = 0
function f2() {
n2 -= 1
n2 += 1
}

0 comments on commit 81b8822

Please sign in to comment.