fez-lisp 1.5.61 → 1.5.64
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/lib/baked/std.js +1 -1
- package/package.json +1 -1
- package/src/check.js +58 -14
package/package.json
CHANGED
package/src/check.js
CHANGED
@@ -81,8 +81,8 @@ const formatType = (name, env) => {
|
|
81
81
|
? `${name} (${(stats[ARGUMENTS] ?? [])
|
82
82
|
.map(
|
83
83
|
(x) =>
|
84
|
-
`${x[STATS][SIGNATURE]} ${x[STATS][TYPE_PROP].map(
|
85
|
-
toTypeNames
|
84
|
+
`${x[STATS][SIGNATURE]} ${x[STATS][TYPE_PROP].map((x) =>
|
85
|
+
toTypeNames(x)
|
86
86
|
).join(' ')}${
|
87
87
|
getSuffix(x[STATS][SIGNATURE]) === PREDICATE_SUFFIX
|
88
88
|
? ' ' + toTypeNames(PREDICATE)
|
@@ -1259,15 +1259,19 @@ export const typeCheck = (ast) => {
|
|
1259
1259
|
const isKnown = T[TYPE_PROP][0] !== UNKNOWN
|
1260
1260
|
switch (first[VALUE]) {
|
1261
1261
|
case 'xs':
|
1262
|
+
case 'arr':
|
1263
|
+
case 'matrix':
|
1264
|
+
case 'table':
|
1262
1265
|
if (isKnown && T[TYPE_PROP][0] !== COLLECTION) {
|
1263
1266
|
warningStack.add(
|
1264
|
-
`A variable named
|
1267
|
+
`A variable named ${first[VALUE]} must be of type (${
|
1265
1268
|
STATIC_TYPES.COLLECTION
|
1266
1269
|
}) but got type (${toTypeNames(
|
1267
1270
|
T[TYPE_PROP][0]
|
1268
1271
|
)}) (check #32)`
|
1269
1272
|
)
|
1270
|
-
}
|
1273
|
+
}
|
1274
|
+
//else T[TYPE_PROP] = [COLLECTION]
|
1271
1275
|
break
|
1272
1276
|
default:
|
1273
1277
|
{
|
@@ -1646,6 +1650,16 @@ export const typeCheck = (ast) => {
|
|
1646
1650
|
}
|
1647
1651
|
for (let i = 0; i < params.length; ++i) {
|
1648
1652
|
const param = params[i]
|
1653
|
+
// TODO move this somewhere else
|
1654
|
+
if (!isLeaf(param)) {
|
1655
|
+
warningStack.add(
|
1656
|
+
`Invalid body for (${
|
1657
|
+
first[VALUE]
|
1658
|
+
}) if it takes more than one expression it must be wrapped in a (${
|
1659
|
+
KEYWORDS.BLOCK
|
1660
|
+
}) (${stringifyArgs(exp)}) (check #666)`
|
1661
|
+
)
|
1662
|
+
}
|
1649
1663
|
copy[param[VALUE]] = {
|
1650
1664
|
[STATS]: {
|
1651
1665
|
[SIGNATURE]: param[VALUE],
|
@@ -1710,6 +1724,7 @@ export const typeCheck = (ast) => {
|
|
1710
1724
|
if (copy[ret[VALUE]])
|
1711
1725
|
ref[STATS][RETURNS] =
|
1712
1726
|
copy[ret[VALUE]][STATS][RETURNS]
|
1727
|
+
// function is anonymous
|
1713
1728
|
break
|
1714
1729
|
}
|
1715
1730
|
}
|
@@ -1743,6 +1758,7 @@ export const typeCheck = (ast) => {
|
|
1743
1758
|
)
|
1744
1759
|
} else {
|
1745
1760
|
const isSpecial = SPECIAL_FORMS_SET.has(first[VALUE])
|
1761
|
+
|
1746
1762
|
if (first[TYPE] === APPLY && !isSpecial) {
|
1747
1763
|
if (env[first[VALUE]][STATS][TYPE_PROP][0] === ATOM) {
|
1748
1764
|
errorStack.add(
|
@@ -1863,16 +1879,31 @@ export const typeCheck = (ast) => {
|
|
1863
1879
|
env[current[VALUE]] &&
|
1864
1880
|
env[current[VALUE]][STATS][RETURNS][1] !== PRED_TYPE
|
1865
1881
|
) {
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
)
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1882
|
+
if (
|
1883
|
+
current[VALUE] === KEYWORDS.ANONYMOUS_FUNCTION
|
1884
|
+
) {
|
1885
|
+
const body = rest[i].at(-1)
|
1886
|
+
const rem = hasBlock(body) ? body.at(-1) : body
|
1887
|
+
const returns = isLeaf(rem) ? rem : rem[0]
|
1888
|
+
if (
|
1889
|
+
env[returns[VALUE]] &&
|
1890
|
+
root[returns[VALUE]][STATS][RETURNS][1] ===
|
1891
|
+
PREDICATE
|
1892
|
+
) {
|
1893
|
+
// TODO invert this logic
|
1894
|
+
} else {
|
1895
|
+
errorStack.add(
|
1896
|
+
`Incorrect type of arguments (${i}) for (${
|
1897
|
+
first[VALUE]
|
1898
|
+
}). Expected (${toTypeNames(
|
1899
|
+
PRED_TYPE
|
1900
|
+
)}) but got (${toTypeNames(
|
1901
|
+
env[current[VALUE]][STATS][RETURNS][1] ??
|
1902
|
+
env[current[VALUE]][STATS][RETURNS][0]
|
1903
|
+
)}) (${stringifyArgs(exp)}) (check #21)`
|
1904
|
+
)
|
1905
|
+
}
|
1906
|
+
}
|
1876
1907
|
}
|
1877
1908
|
}
|
1878
1909
|
}
|
@@ -2093,6 +2124,19 @@ export const typeCheck = (ast) => {
|
|
2093
2124
|
) {
|
2094
2125
|
args[i][STATS].retried += 1
|
2095
2126
|
stack.unshift(() => check(exp, env, scope))
|
2127
|
+
} else {
|
2128
|
+
if (
|
2129
|
+
env[rest[i][VALUE]] &&
|
2130
|
+
args[i][STATS][TYPE_PROP][0] !== UNKNOWN &&
|
2131
|
+
env[rest[i][VALUE]][STATS][TYPE_PROP][0] ===
|
2132
|
+
UNKNOWN &&
|
2133
|
+
args[i][STATS][TYPE_PROP][0] !== APPLY
|
2134
|
+
) {
|
2135
|
+
env[rest[i][VALUE]][STATS][TYPE_PROP] =
|
2136
|
+
args[i][STATS][TYPE_PROP]
|
2137
|
+
env[rest[i][VALUE]][STATS][RETURNS] =
|
2138
|
+
args[i][STATS][RETURNS]
|
2139
|
+
}
|
2096
2140
|
}
|
2097
2141
|
}
|
2098
2142
|
} else if (
|