fez-lisp 1.5.63 → 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/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.63",
5
+ "version": "1.5.64",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -1270,7 +1270,8 @@ export const typeCheck = (ast) => {
1270
1270
  T[TYPE_PROP][0]
1271
1271
  )}) (check #32)`
1272
1272
  )
1273
- } else T[TYPE_PROP] = [COLLECTION]
1273
+ }
1274
+ //else T[TYPE_PROP] = [COLLECTION]
1274
1275
  break
1275
1276
  default:
1276
1277
  {
@@ -1723,6 +1724,7 @@ export const typeCheck = (ast) => {
1723
1724
  if (copy[ret[VALUE]])
1724
1725
  ref[STATS][RETURNS] =
1725
1726
  copy[ret[VALUE]][STATS][RETURNS]
1727
+ // function is anonymous
1726
1728
  break
1727
1729
  }
1728
1730
  }
@@ -1756,6 +1758,7 @@ export const typeCheck = (ast) => {
1756
1758
  )
1757
1759
  } else {
1758
1760
  const isSpecial = SPECIAL_FORMS_SET.has(first[VALUE])
1761
+
1759
1762
  if (first[TYPE] === APPLY && !isSpecial) {
1760
1763
  if (env[first[VALUE]][STATS][TYPE_PROP][0] === ATOM) {
1761
1764
  errorStack.add(
@@ -1876,16 +1879,31 @@ export const typeCheck = (ast) => {
1876
1879
  env[current[VALUE]] &&
1877
1880
  env[current[VALUE]][STATS][RETURNS][1] !== PRED_TYPE
1878
1881
  ) {
1879
- errorStack.add(
1880
- `Incorrect type of arguments (${i}) for (${
1881
- first[VALUE]
1882
- }). Expected (${toTypeNames(
1883
- PRED_TYPE
1884
- )}) but got (${toTypeNames(
1885
- env[current[VALUE]][STATS][RETURNS][1] ??
1886
- env[current[VALUE]][STATS][RETURNS][0]
1887
- )}) (${stringifyArgs(exp)}) (check #21)`
1888
- )
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
+ }
1889
1907
  }
1890
1908
  }
1891
1909
  }
@@ -2106,6 +2124,19 @@ export const typeCheck = (ast) => {
2106
2124
  ) {
2107
2125
  args[i][STATS].retried += 1
2108
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
+ }
2109
2140
  }
2110
2141
  }
2111
2142
  } else if (