fez-lisp 1.6.74 → 1.6.76

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.74",
5
+ "version": "1.6.76",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -45,7 +45,6 @@ import {
45
45
  IS_ARGUMENT,
46
46
  NUMBER,
47
47
  NUMBER_SUBTYPE,
48
- UNKNOWN_SUBTYPE,
49
48
  SubType,
50
49
  GET_ARRAY_INFERENCE_SET
51
50
  } from './types.js'
@@ -57,8 +56,7 @@ import {
57
56
  log,
58
57
  logExp,
59
58
  stringifyArgs,
60
- wrapInApplyLambda,
61
- wrapInBlock
59
+ wrapInApplyLambda
62
60
  } from './utils.js'
63
61
 
64
62
  export const identity = (name) => [
@@ -625,7 +623,9 @@ const resolveGetterRec = ([head, tail], env, times = 0) => {
625
623
  if (head !== WORD && head !== APPLY) return
626
624
  const prop = head === WORD ? TYPE_PROP : RETURNS
627
625
  if (!env[tail] || env[tail][STATS][prop][0] === UNKNOWN) return
628
- const types = env[tail][STATS][prop][1].types
626
+ const types = isSubType(env[tail][STATS][prop][1])
627
+ ? env[tail][STATS][prop][1].types
628
+ : []
629
629
  const sub = types.at(-1)
630
630
  const type =
631
631
  sub === ATOM || sub === NUMBER || sub === BOOLEAN
@@ -634,7 +634,7 @@ const resolveGetterRec = ([head, tail], env, times = 0) => {
634
634
  ? APPLY
635
635
  : COLLECTION
636
636
  const len = types.length ? types.length + 1 : times + 1
637
- return [times, len, type, types]
637
+ return [times, len, type, types, tail]
638
638
  }
639
639
  }
640
640
  const resolveGetter = ({ rem, prop, name, env, caller, exp }) => {
@@ -864,27 +864,36 @@ const resolveSetter = (first, rest, env, stack) => {
864
864
  // )
865
865
  }
866
866
  }
867
- const initArrayTypeRec = ({ rem, env }) => {
868
- return rem.slice(1).map((x) =>
869
- isLeaf(x)
870
- ? x[TYPE] === WORD
871
- ? env[x[VALUE]]
872
- ? // env[x[VALUE]][STATS][TYPE_PROP][0] === COLLECTION
873
- // ? initArrayTypeRec({ rem: x, env })
874
- // :
875
- getTypes(env[x[VALUE]][STATS])
876
- : [UNKNOWN]
877
- : [
878
- x[TYPE],
879
- x[TYPE] === ATOM ? NUMBER_SUBTYPE() : new SubType([UNKNOWN])
880
- ]
881
- : env[x[0][VALUE]]
882
- ? x.length > 1 && env[x[0][VALUE]][STATS][RETURNS][0] === COLLECTION
883
- ? initArrayTypeRec({ rem: x, env })
884
- : getReturns(env[x[0][VALUE]][STATS])
885
- : [UNKNOWN]
886
- )
887
- }
867
+ const initArrayTypeRec = ({ rem, env }) =>
868
+ rem.slice(1).map((x) => {
869
+ if (isLeaf(x))
870
+ if (x[TYPE] === WORD)
871
+ if (env[x[VALUE]]) return getTypes(env[x[VALUE]][STATS])
872
+ else return [UNKNOWN]
873
+ else
874
+ return [
875
+ x[TYPE],
876
+ x[TYPE] === ATOM ? NUMBER_SUBTYPE() : new SubType([UNKNOWN])
877
+ ]
878
+ else if (env[x[0][VALUE]])
879
+ if (x.length > 1 && env[x[0][VALUE]][STATS][RETURNS][0] === COLLECTION)
880
+ return initArrayTypeRec({ rem: x, env })
881
+ else if (GET_ARRAY_INFERENCE_SET.has(x[0][VALUE])) {
882
+ const res = resolveGetterRec(x, env)
883
+ if (!res) return [UNKNOWN]
884
+ const name = resolveGetterRec(x, env).at(-1)
885
+ resolveGetter({
886
+ rem: x,
887
+ prop: RETURNS,
888
+ name,
889
+ env,
890
+ caller: x[0][VALUE],
891
+ exp: rem
892
+ })
893
+ return getReturns(env[name][STATS])
894
+ } else return getReturns(env[x[0][VALUE]][STATS])
895
+ else return [UNKNOWN]
896
+ })
888
897
  const initArrayType = ({ rem, env }) => {
889
898
  const ret = initArrayTypeRec({ rem, env })
890
899
  const known = ret.find((x) => x[0] !== ANY && x[0] !== UNKNOWN)
package/src/types.js CHANGED
@@ -23,6 +23,7 @@ export const RETURNS = 'returns'
23
23
  export const SCOPE_NAME = '__scope__'
24
24
  export const TYPE_PROP = 'type'
25
25
  export const SIGNATURE = 'name'
26
+ export const UNBOUND_VARIABLE = '__unbound__'
26
27
  export const UNKNOWN = -1
27
28
  export const COLLECTION = 3
28
29
  export const BOOLEAN = 5