fez-lisp 1.6.66 → 1.6.68
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 +1 -1
- package/src/check.js +17 -2
- package/src/macros.js +11 -0
package/package.json
CHANGED
package/src/check.js
CHANGED
@@ -617,6 +617,8 @@ const resolveGetter = ({ rem, prop, name, env, caller, exp }) => {
|
|
617
617
|
if (!env[array[VALUE]] || !env[name]) return true
|
618
618
|
switch (array[TYPE]) {
|
619
619
|
case APPLY:
|
620
|
+
// TODO: figure out recursively what is the inner type of all nested getters
|
621
|
+
if (GET_ARRAY_INFERENCE_SET.has(array[VALUE])) return true
|
620
622
|
if (
|
621
623
|
getReturn(env[array[VALUE]][STATS]) === UNKNOWN ||
|
622
624
|
getReturn(env[array[VALUE]][STATS]) === ANY
|
@@ -828,6 +830,7 @@ const initArrayTypeRec = ({ rem, env }) => {
|
|
828
830
|
const initArrayType = ({ rem, env }) => {
|
829
831
|
const ret = initArrayTypeRec({ rem, env })
|
830
832
|
const known = ret.find((x) => x[0] !== ANY && x[0] !== UNKNOWN)
|
833
|
+
const isCollection = ret.length && ret[0] && ret[0][0] === COLLECTION
|
831
834
|
if (known && ret.length) {
|
832
835
|
if (Array.isArray(ret[0][0])) {
|
833
836
|
let head = ret[0][0]
|
@@ -844,12 +847,24 @@ const initArrayType = ({ rem, env }) => {
|
|
844
847
|
if (isSubType(sub) && sub.types.at(-1) === COLLECTION) sub.types.pop()
|
845
848
|
return {
|
846
849
|
[TYPE_PROP]: [APPLY],
|
847
|
-
[RETURNS]: [
|
850
|
+
[RETURNS]: [
|
851
|
+
COLLECTION,
|
852
|
+
isCollection
|
853
|
+
? new SubType(
|
854
|
+
isSubType(sub) ? [COLLECTION, ...sub] : [COLLECTION, main]
|
855
|
+
)
|
856
|
+
: new SubType(isSubType(sub) ? [...sub] : [main])
|
857
|
+
]
|
848
858
|
}
|
849
859
|
} else
|
850
860
|
return {
|
851
861
|
[TYPE_PROP]: [APPLY],
|
852
|
-
[RETURNS]: [
|
862
|
+
[RETURNS]: [
|
863
|
+
COLLECTION,
|
864
|
+
isCollection
|
865
|
+
? new SubType([COLLECTION, UNKNOWN])
|
866
|
+
: new SubType([UNKNOWN])
|
867
|
+
]
|
853
868
|
}
|
854
869
|
}
|
855
870
|
const resolveReturnType = ({
|
package/src/macros.js
CHANGED
@@ -118,6 +118,17 @@ export const deSuggarAst = (ast, scope) => {
|
|
118
118
|
if (rest.length === 1) {
|
119
119
|
exp[0][VALUE] = 'math:var-get'
|
120
120
|
// exp.push([ATOM, 0])
|
121
|
+
} else if (rest.length > 2) {
|
122
|
+
exp.length = 0
|
123
|
+
rest.reverse()
|
124
|
+
let temp = exp
|
125
|
+
for (let i = 0; i < rest.length; i += 1) {
|
126
|
+
if (i < rest.length - 1) {
|
127
|
+
temp.push([APPLY, SUGGAR.GET_ARRAY], [], rest[i])
|
128
|
+
temp = temp.at(-2)
|
129
|
+
} else temp.push(...rest[i])
|
130
|
+
}
|
131
|
+
deSuggarAst(exp, scope)
|
121
132
|
}
|
122
133
|
break
|
123
134
|
case SUGGAR.INCREMENT:
|