Skip to content

Commit

Permalink
Merge pull request #223 from commonlisp/master
Browse files Browse the repository at this point in the history
Removed hard-coded .length case
  • Loading branch information
gabelevi committed Jan 22, 2015
2 parents 0de91ac + 05f3d65 commit 16ebd0f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/typing/flow_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1262,12 +1262,6 @@ let rec flow cx (l,u) trace =
| (_,
(GetT(_,"toLocaleString",_) | SetT(_,"toLocaleString",_))) -> ()

| ((ObjT _ | ArrT _), GetT(reason_op,"length",tout)) ->
unit_flow cx (NumT.why reason_op, tout)

| ((ObjT _ | ArrT _),
(SetT(_,"length",_) | MethodT(_,"length",_,_,_,_))) -> ()

| ((ObjT _ | ArrT _), GetT(reason_op,"constructor",tout)) ->
unit_flow cx (AnyT.why reason_op, tout)

Expand Down
2 changes: 2 additions & 0 deletions tests/misc/F.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
function fn2(x) { return x.length * 4; }
fn2({length: 'hi'});
3 changes: 3 additions & 0 deletions tests/misc/G.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var a = { length: "duck" };
a.length = 123;
a.length();
14 changes: 13 additions & 1 deletion tests/misc/misc.exp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ E.js:8:6,10: boolean
This type is incompatible with
E.js:4:14,19: number

Found 3 errors
F.js:2:14,17: string
This type is incompatible with
F.js:1:26,37: number

G.js:2:12,14: number
This type is incompatible with
G.js:1:19,24: string

G.js:3:1,10: call of method length
Function cannot be called on
G.js:1:19,24: string

Found 6 errors

0 comments on commit 16ebd0f

Please sign in to comment.