fez-lisp 1.6.64 → 1.6.65

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.6.64",
5
+ "version": "1.6.65",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -72,7 +72,6 @@ export const identity = (name) => [
72
72
  ]
73
73
  export const typeSetDefaultFunction = (Types, name, env, exp) =>
74
74
  Types.set(withScope(name, env), () => formatType(name, env))
75
-
76
75
  const returnType = (rest) => {
77
76
  const body = rest.at(-1)
78
77
  const rem = hasBlock(body) ? body.at(-1) : body
@@ -218,6 +217,12 @@ export const setReturnToTypeRef = (stats, value) => {
218
217
  )
219
218
  }
220
219
  export const setStats = (a, b) => (a[STATS] = b[STATS])
220
+ export const cloneStats = (name, x) => ({
221
+ [STATS]: {
222
+ ...x[STATS],
223
+ [SIGNATURE]: name
224
+ }
225
+ })
221
226
  export const setStatsRef = (a, b) => (a[STATS] = b[STATS])
222
227
  export const setTypeToReturnRef = (stats, value) => {
223
228
  // To prevent getters overwritting the array subtype
@@ -687,11 +692,17 @@ const resolveSetter = (first, rest, env, stack) => {
687
692
  case WORD:
688
693
  if (env[right[VALUE]]) {
689
694
  if (hasSubType(env[right[VALUE]][STATS])) {
690
- if (currentSubType.has(UNKNOWN))
691
- current[STATS][TYPE_PROP][1] = new SubType([
692
- ...getSubType(env[right[VALUE]][STATS])
693
- ])
694
- else if (!equalSubTypes(current[STATS], env[right[VALUE]][STATS]))
695
+ if (currentSubType.has(UNKNOWN)) {
696
+ if (env[right[VALUE]][STATS][TYPE_PROP][0] === COLLECTION) {
697
+ current[STATS][TYPE_PROP][1] = new SubType([
698
+ COLLECTION,
699
+ ...getSubType(env[right[VALUE]][STATS]).types
700
+ ])
701
+ } else
702
+ current[STATS][TYPE_PROP][1] = new SubType(
703
+ getSubType(env[right[VALUE]][STATS]).types
704
+ )
705
+ } else if (!equalSubTypes(current[STATS], env[right[VALUE]][STATS]))
695
706
  throw new TypeError(
696
707
  `Incorrect array type at (${
697
708
  first[VALUE]
@@ -701,9 +712,9 @@ const resolveSetter = (first, rest, env, stack) => {
701
712
  getTypes(env[right[VALUE]][STATS])
702
713
  )}) (${stringifyArgs([first, rest])}) (check #198)`
703
714
  )
704
- current[STATS][TYPE_PROP][1] = new SubType(
705
- getSubType(env[right[VALUE]][STATS])
706
- )
715
+ // current[STATS][TYPE_PROP][1] = new SubType(
716
+ // getSubType(env[right[VALUE]][STATS])
717
+ // )
707
718
  } else
708
719
  retry(env[right[VALUE]][STATS], [first[VALUE], rest], stack, () =>
709
720
  resolveSetter(first, rest, env, stack)
@@ -722,11 +733,17 @@ const resolveSetter = (first, rest, env, stack) => {
722
733
  break
723
734
  }
724
735
  if (hasSubReturn(env[right[VALUE]][STATS])) {
725
- if (currentSubType.has(UNKNOWN))
726
- current[STATS][TYPE_PROP][1] = new SubType([
727
- ...getSubReturn(env[right[VALUE]][STATS])
728
- ])
729
- else if (
736
+ if (currentSubType.has(UNKNOWN)) {
737
+ if (env[right[VALUE]][STATS][RETURNS][0] === COLLECTION) {
738
+ current[STATS][TYPE_PROP][1] = new SubType([
739
+ COLLECTION,
740
+ ...getSubReturn(env[right[VALUE]][STATS]).types
741
+ ])
742
+ } else
743
+ current[STATS][TYPE_PROP][1] = new SubType(
744
+ getSubReturn(env[right[VALUE]][STATS]).types
745
+ )
746
+ } else if (
730
747
  !equalSubTypesWithSubReturn(
731
748
  current[STATS],
732
749
  env[right[VALUE]][STATS]
@@ -741,9 +758,9 @@ const resolveSetter = (first, rest, env, stack) => {
741
758
  getReturns(env[right[VALUE]][STATS])
742
759
  )}) (${stringifyArgs([first, rest])}) (check #198)`
743
760
  )
744
- current[STATS][TYPE_PROP][1] = new SubType([
745
- ...getSubReturn(env[right[VALUE]][STATS])
746
- ])
761
+ // current[STATS][TYPE_PROP][1] = new SubType([
762
+ // ...getSubReturn(env[right[VALUE]][STATS])
763
+ // ])
747
764
  }
748
765
  // else
749
766
  // retry(env[right[VALUE]][STATS], [first[VALUE], rest], stack, () =>
@@ -753,6 +770,7 @@ const resolveSetter = (first, rest, env, stack) => {
753
770
  break
754
771
  }
755
772
  setTypeToCollection(current[STATS])
773
+
756
774
  // // Retry setting the sub-type if infered it out later
757
775
  // if (!hasSubType(current[STATS]) || getSubType(current[STATS]).has(UNKNOWN))
758
776
  // retry(current[STATS], [first[VALUE], rest], stack, () =>
@@ -1421,7 +1439,6 @@ export const typeCheck = (
1421
1439
  check(rightHand, env, scope)
1422
1440
  }
1423
1441
  typeSet(Types, name, env, exp)
1424
- // Types.set(withScope(name, env), () => formatType(name, env))
1425
1442
  break
1426
1443
  case KEYWORDS.ANONYMOUS_FUNCTION:
1427
1444
  {