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

Removed hard-coded .length case #223

Merged
merged 1 commit into from
Jan 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm...I don't see an F.js. Did you add it and forget to add it to the commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Yes, F.js was missed in the commit. I corrected that now. Thanks!

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