@@ -27,6 +27,7 @@ task name expr portType =
2727
2828data JSType
2929 = JSNumber
30+ | JSIntNumber
3031 | JSBoolean
3132 | JSString
3233 | JSArray
@@ -37,6 +38,7 @@ typeToString :: JSType -> String
3738typeToString tipe =
3839 case tipe of
3940 JSNumber -> "a number"
41+ JSIntNumber -> "an integer"
4042 JSBoolean -> "a boolean (true or false)"
4143 JSString -> "a string"
4244 JSArray -> "an array"
@@ -82,12 +84,19 @@ check x jsType continue =
8284 checks =
8385 case jsType of
8486 JSNumber -> [typeof "number"]
87+ JSIntNumber ->
88+ [jsFold OpLAnd (typeof "number" : intChecks)]
8589 JSBoolean -> [typeof "boolean"]
8690 JSString -> [typeof "string", instanceof "String"]
8791 JSArray -> [instanceof "Array"]
8892 JSObject fields ->
8993 [jsFold OpLAnd (typeof "object" : map member fields)]
9094
95+ intChecks =
96+ [ \x -> (ref "isFinite") `call` [x]
97+ , \x -> equal (obj ["Math","floor"] `call` [x]) x
98+ ]
99+
91100
92101-- INBOUND
93102
@@ -127,8 +136,8 @@ toType tipe x =
127136 toType (T.dealias args t) x
128137
129138 T.Type (Var.Canonical Var.BuiltIn name)
130− | name == "Int" -> from JSNumber
131139 | name == "Float" -> from JSNumber
140+ | name == "Int" -> from JSIntNumber
132141 | name == "Bool" -> from JSBoolean
133142 | name == "String" -> from JSString
134143 where