fez-lisp 1.5.78 → 1.5.79

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/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.78",
5
+ "version": "1.5.79",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -1036,8 +1036,30 @@ export const typeCheck = (ast) => {
1036
1036
  exp
1037
1037
  )}) (check #13)`
1038
1038
  )
1039
+ } else if (
1040
+ T === APPLY &&
1041
+ args[i][STATS][TYPE_PROP][0] !== UNKNOWN &&
1042
+ env[rest[i][VALUE]][STATS][TYPE_PROP][0] !== UNKNOWN &&
1043
+ env[rest[i][VALUE]][STATS][ARG_COUNT] !== VARIADIC
1044
+ ) {
1045
+ // Handles words that are Lambdas
1046
+ if (
1047
+ env[rest[i][VALUE]][STATS][ARG_COUNT] !==
1048
+ args[i][STATS][ARG_COUNT]
1049
+ ) {
1050
+ errorStack.add(
1051
+ `Incorrect number of arguments for (${
1052
+ args[i][STATS][SIGNATURE]
1053
+ }) the (lambda) argument of (${
1054
+ first[VALUE]
1055
+ }) at position (${i}). Expected (= ${
1056
+ args[i][STATS][ARG_COUNT]
1057
+ }) but got ${
1058
+ env[rest[i][VALUE]][STATS][ARG_COUNT]
1059
+ } (${stringifyArgs(exp)}) (check #778)`
1060
+ )
1061
+ }
1039
1062
  }
1040
-
1041
1063
  if (
1042
1064
  env[rest[i][VALUE]] &&
1043
1065
  env[rest[i][VALUE]][STATS][TYPE_PROP][0] !== UNKNOWN &&
@@ -1074,11 +1096,7 @@ export const typeCheck = (ast) => {
1074
1096
  args[i][STATS][RETURNS]
1075
1097
  }
1076
1098
  }
1077
- } else if (
1078
- rest[i].length &&
1079
- rest[i][0][TYPE] === APPLY &&
1080
- env[rest[i][0][VALUE]]
1081
- ) {
1099
+ } else if (env[rest[i][0][VALUE]]) {
1082
1100
  const match = () => {
1083
1101
  const actual = env[rest[i][0][VALUE]][STATS][RETURNS]
1084
1102
  const expected = args[i][STATS][TYPE_PROP]
@@ -1099,6 +1117,7 @@ export const typeCheck = (ast) => {
1099
1117
  )
1100
1118
  else {
1101
1119
  switch (expected[0]) {
1120
+ // almost exclusively for anonymous lambdas
1102
1121
  case APPLY:
1103
1122
  {
1104
1123
  const argsN = rest[i].length - 2
@@ -1109,17 +1128,24 @@ export const typeCheck = (ast) => {
1109
1128
  if (argsN !== args[i][STATS][ARG_COUNT]) {
1110
1129
  errorStack.add(
1111
1130
  `Incorrect number of arguments for (${
1131
+ args[i][STATS][SIGNATURE]
1132
+ }) the (lambda) argument of (${
1112
1133
  first[VALUE]
1113
- }). Expected (= ${
1114
- env[first[VALUE]][STATS][ARG_COUNT]
1115
- }) but got ${
1116
- rest.length
1117
- } (${stringifyArgs(exp)}) (check #777)`
1134
+ }) at position (${i}). Expected (= ${
1135
+ args[i][STATS][ARG_COUNT]
1136
+ }) but got ${argsN} (${stringifyArgs(
1137
+ exp
1138
+ )}) (check #777)`
1118
1139
  )
1119
1140
  }
1141
+ } else {
1142
+ // TODO fix curry: lambdas enter here as undefined
1120
1143
  }
1121
1144
  }
1122
1145
  break
1146
+ // case ATOM:
1147
+ // case COLLECTION:
1148
+ // break
1123
1149
  }
1124
1150
  }
1125
1151
  } else if (
@@ -1130,7 +1156,6 @@ export const typeCheck = (ast) => {
1130
1156
  stack.unshift(() => match())
1131
1157
  }
1132
1158
  }
1133
-
1134
1159
  match()
1135
1160
  }
1136
1161
  }
@@ -1149,7 +1174,6 @@ export const typeCheck = (ast) => {
1149
1174
  )
1150
1175
  }
1151
1176
  }
1152
-
1153
1177
  check(r, env, scope)
1154
1178
  }
1155
1179
  break