fez-lisp 1.5.17 → 1.5.18

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 +20 -9
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.17",
5
+ "version": "1.5.18",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -412,8 +412,10 @@ export const typeCheck = (ast) => {
412
412
  }
413
413
  }
414
414
  }
415
- const key = withScope(name, scope)
416
- if (errorStack.has(key)) errorStack.delete(key)
415
+ // if (env[SCOPE_NAME]) {
416
+ // const key = withScope(name, scope)
417
+ // if (errorStack.has(key)) errorStack.delete(key)
418
+ // }
417
419
  check(rest.at(-1), env, scope)
418
420
  }
419
421
  }
@@ -491,7 +493,9 @@ export const typeCheck = (ast) => {
491
493
  args[i][STATS].type === APPLY &&
492
494
  env[rest[i][VALUE]] &&
493
495
  env[rest[i][VALUE]][STATS] &&
494
- env[rest[i][VALUE]][STATS][ARGS_COUNT]
496
+ env[rest[i][VALUE]][STATS][ARGS_COUNT] &&
497
+ args[i][STATS][ARGS_COUNT] !== VARIADIC &&
498
+ env[rest[i][VALUE]][STATS][ARGS_COUNT] !== VARIADIC
495
499
  ) {
496
500
  const argCount = [...args[i][STATS][ARGS_COUNT]]
497
501
  if (
@@ -667,11 +671,14 @@ export const typeCheck = (ast) => {
667
671
  )})`
668
672
  )
669
673
  } else {
674
+ // env[rest[i][VALUE]][STATS] THiss SHOULD BE
675
+ const retry = env[rest[i][VALUE]]
670
676
  if (
671
- !args[i][STATS].retried &&
677
+ retry &&
678
+ !retry.retried &&
672
679
  args[i][STATS].type === UNKNOWN
673
680
  ) {
674
- args[i][STATS].retried = true
681
+ retry.retried = true
675
682
  if (!scope[SCOPE_NAME])
676
683
  scope[SCOPE_NAME] = scope[1][VALUE]
677
684
  stack.unshift(() => check(exp, env, scope))
@@ -704,10 +711,12 @@ export const typeCheck = (ast) => {
704
711
  )
705
712
  } else {
706
713
  if (
714
+ rest[i].length &&
715
+ env[rest[i][0][VALUE]] &&
707
716
  args[i][STATS].type === UNKNOWN &&
708
- !args[i][STATS].retried
717
+ !env[rest[i][0][VALUE]].retried
709
718
  ) {
710
- args[i][STATS].retried = true
719
+ env[rest[i][0][VALUE]].retried = true
711
720
  if (!scope[SCOPE_NAME])
712
721
  scope[SCOPE_NAME] = scope[1][VALUE]
713
722
  stack.unshift(() => check(exp, env, scope))
@@ -725,8 +734,10 @@ export const typeCheck = (ast) => {
725
734
  }
726
735
  }
727
736
  }
728
- check(ast, root, ast)
737
+ const copy = JSON.parse(JSON.stringify(ast))
738
+ check(copy, root, copy)
729
739
  while (stack.length) stack.pop()()
730
- if (errorStack.size) throw new TypeError([...errorStack.values()].join('\n'))
740
+ if (errorStack.size)
741
+ throw new TypeError([...new Set(errorStack.values())].join('\n'))
731
742
  return ast
732
743
  }