fez-lisp 1.5.88 → 1.5.89

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 +24 -37
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.88",
5
+ "version": "1.5.89",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -90,6 +90,9 @@ const checkPredicateName = (exp, rest, warningStack) => {
90
90
  } else if (last[0][0] === APPLY) {
91
91
  const application = last[0]
92
92
  switch (application[VALUE]) {
93
+ case KEYWORDS.IF:
94
+ // TODO finishthis #1
95
+ break
93
96
  default:
94
97
  if (
95
98
  getSuffix(application[VALUE]) !== PREDICATE_SUFFIX &&
@@ -107,6 +110,23 @@ const checkPredicateName = (exp, rest, warningStack) => {
107
110
  }
108
111
  }
109
112
  }
113
+ const checkPredicateNameDeep = (name, exp, rest, returns, warningStack) => {
114
+ if (returns[VALUE] === KEYWORDS.CALL_FUNCTION) {
115
+ const fn = rest.at(-1).at(-1).at(-1)
116
+ checkPredicateName(
117
+ exp,
118
+ [
119
+ [WORD, name],
120
+ isLeaf(fn)
121
+ ? fn // when apply is a word (let x? (lambda (apply [] array:empty!)))
122
+ : drillReturnType(fn, (r) => r[VALUE] === KEYWORDS.CALL_FUNCTION) // when apply is an annonymous lambda // (let fn? (lambda x (apply x (lambda x (array:empty! [])))))
123
+ ],
124
+ warningStack
125
+ )
126
+ } else {
127
+ checkPredicateName(exp, [[WORD, name], returns], warningStack)
128
+ }
129
+ }
110
130
  // const assign = (a, b, i) => {
111
131
  // a[i] = b[i]
112
132
  // }
@@ -306,9 +326,11 @@ export const typeCheck = (ast) => {
306
326
  }
307
327
  break
308
328
  default:
309
- checkPredicateName(
329
+ checkPredicateNameDeep(
330
+ name,
310
331
  exp,
311
- [[WORD, name], returns],
332
+ rest,
333
+ returns,
312
334
  warningStack
313
335
  )
314
336
  if (!env[returns[VALUE]])
@@ -317,41 +339,6 @@ export const typeCheck = (ast) => {
317
339
  else if (
318
340
  env[returns[VALUE]][STATS][TYPE_PROP][0] === APPLY
319
341
  ) {
320
- if (returns[VALUE] === KEYWORDS.CALL_FUNCTION) {
321
- const fn = rest.at(-1).at(-1).at(-1)
322
- checkPredicateName(
323
- exp,
324
- [
325
- [WORD, name],
326
- isLeaf(fn)
327
- ? fn // when apply is a word (let x? (lambda (apply [] array:empty!)))
328
- : drillReturnType(
329
- fn,
330
- (r) => r[VALUE] === KEYWORDS.CALL_FUNCTION
331
- ) // when apply is an annonymous lambda // (let fn? (lambda x (apply x (lambda x (array:empty! [])))))
332
- ],
333
- warningStack
334
- )
335
- }
336
-
337
- // TODO This seems to be able to be deleted
338
- // FOR NOT IT CAN BE
339
- // if (returns[VALUE] === KEYWORDS.CALL_FUNCTION) {
340
- // if (isLeaf(rest.at(-1).at(-1).at(-1))) {
341
- // const fnName = rest.at(-1).at(-1).at(-1)[VALUE]
342
- // const fn = env[fnName]
343
- // env[name][STATS][TYPE_PROP][0] =
344
- // fn[STATS][RETURNS][0]
345
- // } else {
346
- // const [returns, rem] = drillReturnType(
347
- // rest.at(-1).at(-1).at(-1),
348
- // (returns) =>
349
- // returns[VALUE] === KEYWORDS.CALL_FUNCTION
350
- // )
351
- // resolveRetunType(returns, rem, TYPE_PROP)
352
- // }
353
- // }
354
-
355
342
  // ALWAYS APPLY
356
343
  // rest.at(-1)[0][TYPE] === APPLY
357
344
  // Here is upon application to store the result in the variable