fez-lisp 1.5.114 → 1.5.115

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/check.js +44 -14
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "fez-lisp",
3
3
  "description": "Lisp interpreted & compiled to JavaScript",
4
4
  "author": "AT290690",
5
- "version": "1.5.114",
5
+ "version": "1.5.115",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
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
- T === ATOM &&
994
- !isUnknownType(args[i][STATS]) &&
995
- getType(args[i][STATS]) !== ATOM
996
- ) {
997
- throw new TypeError(
998
- `Incorrect type of argument (${i}) for (${
999
- first[VALUE]
1000
- }). Expected (${toTypeNames(
1001
- getType(args[i][STATS])
1002
- )}) but got (${toTypeNames(T)}) (${stringifyArgs(
1003
- exp
1004
- )}) (check #10)`
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: