fez-lisp 1.5.114 → 1.5.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/baked/std.js +1 -1
- package/package.json +1 -1
- package/src/check.js +83 -53
package/package.json
CHANGED
package/src/check.js
CHANGED
@@ -989,20 +989,40 @@ export const typeCheck = (ast, error = true) => {
|
|
989
989
|
? getType(env[rest[i][VALUE]][STATS])
|
990
990
|
: UNKNOWN
|
991
991
|
: rest[i][TYPE]
|
992
|
-
if (
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
)
|
1003
|
-
|
1004
|
-
|
992
|
+
if (T === ATOM && !isUnknownType(args[i][STATS])) {
|
993
|
+
if (getType(args[i][STATS]) !== ATOM)
|
994
|
+
throw new TypeError(
|
995
|
+
`Incorrect type of argument (${i}) for (${
|
996
|
+
first[VALUE]
|
997
|
+
}). Expected (${toTypeNames(
|
998
|
+
getType(args[i][STATS])
|
999
|
+
)}) but got (${toTypeNames(T)}) (${stringifyArgs(
|
1000
|
+
exp
|
1001
|
+
)}) (check #10)`
|
1002
|
+
)
|
1003
|
+
else if (
|
1004
|
+
rest[i][TYPE] === ATOM
|
1005
|
+
? hasSubType(args[i][STATS]) &&
|
1006
|
+
getSubType(args[i][STATS]).has(PREDICATE) &&
|
1007
|
+
!isAtomABoolean(rest[i][VALUE])
|
1008
|
+
: notABooleanType(
|
1009
|
+
args[i][STATS],
|
1010
|
+
env[rest[i][VALUE]][STATS]
|
1011
|
+
)
|
1005
1012
|
)
|
1013
|
+
throw new TypeError(
|
1014
|
+
`Incorrect type of argument (${i}) for special form (${
|
1015
|
+
first[VALUE]
|
1016
|
+
}). Expected (${formatSubType(
|
1017
|
+
getTypes(args[i][STATS])
|
1018
|
+
)}) but got (${
|
1019
|
+
rest[i][TYPE] === ATOM
|
1020
|
+
? toTypeNames(rest[i][TYPE])
|
1021
|
+
: formatSubType(
|
1022
|
+
getTypes(env[rest[i][VALUE]][STATS])
|
1023
|
+
)
|
1024
|
+
}) (${stringifyArgs(exp)}) (check #205)`
|
1025
|
+
)
|
1006
1026
|
} else if (
|
1007
1027
|
T === APPLY &&
|
1008
1028
|
!isUnknownType(args[i][STATS]) &&
|
@@ -1158,7 +1178,17 @@ export const typeCheck = (ast, error = true) => {
|
|
1158
1178
|
getReturn(actual)
|
1159
1179
|
)}) (${stringifyArgs(exp)}) (check #16)`
|
1160
1180
|
)
|
1161
|
-
else {
|
1181
|
+
else if (notABooleanReturn(expected, actual)) {
|
1182
|
+
throw new TypeError(
|
1183
|
+
`Incorrect type of argument (${i}) for special form (${
|
1184
|
+
first[VALUE]
|
1185
|
+
}). Expected (${formatSubType(
|
1186
|
+
getTypes(expected)
|
1187
|
+
)}) but got (${formatSubType(
|
1188
|
+
getReturns(actual)
|
1189
|
+
)}) (${stringifyArgs(exp)}) (check #204)`
|
1190
|
+
)
|
1191
|
+
} else {
|
1162
1192
|
switch (getType(expected)) {
|
1163
1193
|
// almost exclusively for anonymous lambdas
|
1164
1194
|
case APPLY:
|
@@ -1284,45 +1314,45 @@ export const typeCheck = (ast, error = true) => {
|
|
1284
1314
|
}
|
1285
1315
|
|
1286
1316
|
// handly typehints for arrays
|
1287
|
-
if (
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
) {
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
}
|
1317
|
+
// if (
|
1318
|
+
// first[TYPE] === APPLY &&
|
1319
|
+
// MUTATORS_SET.has(first[VALUE]) &&
|
1320
|
+
// env[first[VALUE]]
|
1321
|
+
// ) {
|
1322
|
+
// const current = env[rest[i][VALUE]]
|
1323
|
+
// if (current) {
|
1324
|
+
// if (rest[i][TYPE] === WORD) {
|
1325
|
+
// if (!current[STATS][TYPE_PROP][1]) {
|
1326
|
+
// current[STATS][TYPE_PROP][1] = new Set()
|
1327
|
+
// }
|
1328
|
+
// if (MULTI_DIMENTIONAL_SETTERS.has(first[VALUE])) {
|
1329
|
+
// current[STATS][TYPE_PROP][1].add(COLLECTION)
|
1330
|
+
// } else {
|
1331
|
+
// const right = isLeaf(rest.at(-1))
|
1332
|
+
// ? rest.at(-1)
|
1333
|
+
// : rest.at(-1)[0]
|
1334
|
+
// switch (right[TYPE]) {
|
1335
|
+
// case ATOM:
|
1336
|
+
// current[STATS][TYPE_PROP][1].add(ATOM)
|
1337
|
+
// break
|
1338
|
+
// case WORD:
|
1339
|
+
// if (env[right[VALUE]]) {
|
1340
|
+
// current[STATS][TYPE_PROP][1].add(
|
1341
|
+
// ...env[right[VALUE]][STATS][TYPE_PROP]
|
1342
|
+
// )
|
1343
|
+
// }
|
1344
|
+
// break
|
1345
|
+
// case APPLY:
|
1346
|
+
// if (env[right[VALUE]])
|
1347
|
+
// current[STATS][TYPE_PROP][1].add(
|
1348
|
+
// ...env[right[VALUE]][STATS][RETURNS]
|
1349
|
+
// )
|
1350
|
+
// break
|
1351
|
+
// }
|
1352
|
+
// }
|
1353
|
+
// }
|
1354
|
+
// }
|
1355
|
+
// }
|
1326
1356
|
// handly typehints for arrays
|
1327
1357
|
}
|
1328
1358
|
}
|