fez-lisp 1.5.60 → 1.5.61

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.60",
5
+ "version": "1.5.61",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -84,10 +84,8 @@ const formatType = (name, env) => {
84
84
  `${x[STATS][SIGNATURE]} ${x[STATS][TYPE_PROP].map(
85
85
  toTypeNames
86
86
  ).join(' ')}${
87
- x[STATS][TYPE_PROP][0] === APPLY
88
- ? ` ${toTypeNames(
89
- x[STATS][RETURNS][1] ?? x[STATS][RETURNS][0]
90
- )}`
87
+ getSuffix(x[STATS][SIGNATURE]) === PREDICATE_SUFFIX
88
+ ? ' ' + toTypeNames(PREDICATE)
91
89
  : ''
92
90
  }`
93
91
  )
@@ -1959,7 +1957,7 @@ export const typeCheck = (ast) => {
1959
1957
  )}) (${stringifyArgs(exp)}) (check #3)`
1960
1958
  )
1961
1959
  } else if (
1962
- PRED_TYPE &&
1960
+ PRED_TYPE === PREDICATE &&
1963
1961
  env[CAR][STATS][RETURNS][1] !==
1964
1962
  PRED_TYPE &&
1965
1963
  !isCast
@@ -1999,6 +1997,21 @@ export const typeCheck = (ast) => {
1999
1997
  )}) (${stringifyArgs(exp)}) (check #2)`
2000
1998
  )
2001
1999
  }
2000
+ if (
2001
+ PRED_TYPE === PREDICATE &&
2002
+ rest[i][VALUE] !== TRUE &&
2003
+ rest[i][VALUE] !== FALSE
2004
+ ) {
2005
+ errorStack.add(
2006
+ `Incorrect type of argument (${i}) for special form (${
2007
+ first[VALUE]
2008
+ }). Expected (${toTypeNames(
2009
+ PRED_TYPE
2010
+ )}) but got (${toTypeNames(
2011
+ rest[i][VALUE]
2012
+ )}) (${stringifyArgs(exp)}) (check #5)`
2013
+ )
2014
+ }
2002
2015
  break
2003
2016
  }
2004
2017
  }
@@ -2016,16 +2029,45 @@ export const typeCheck = (ast) => {
2016
2029
  rest[i][TYPE] === WORD && env[rest[i][VALUE]]
2017
2030
  ? env[rest[i][VALUE]][STATS][TYPE_PROP][0]
2018
2031
  : rest[i][TYPE]
2019
- if (
2020
- (args[i][STATS][TYPE_PROP][0] !== UNKNOWN &&
2021
- T === ATOM &&
2022
- args[i][STATS][TYPE_PROP][0] !== ATOM) ||
2023
- (env[rest[i][VALUE]] &&
2024
- env[rest[i][VALUE]][STATS][TYPE_PROP][0] !==
2025
- UNKNOWN &&
2032
+ if (T === ATOM) {
2033
+ if (
2026
2034
  args[i][STATS][TYPE_PROP][0] !== UNKNOWN &&
2027
- env[rest[i][VALUE]][STATS][TYPE_PROP][0] !==
2028
- args[i][STATS][TYPE_PROP][0])
2035
+ args[i][STATS][TYPE_PROP][0] !== ATOM
2036
+ ) {
2037
+ errorStack.add(
2038
+ `Incorrect type of arguments ${i} for (${
2039
+ first[VALUE]
2040
+ }). Expected (${toTypeNames(
2041
+ args[i][STATS][TYPE_PROP][0]
2042
+ )}) but got (${toTypeNames(
2043
+ T
2044
+ )}) (${stringifyArgs(exp)}) (check #10)`
2045
+ )
2046
+ } else if (
2047
+ args[i][STATS][RETURNS][0] === ATOM &&
2048
+ args[i][STATS][RETURNS][1] === PREDICATE &&
2049
+ rest[i][VALUE] !== TRUE &&
2050
+ rest[i][VALUE] !== FALSE
2051
+ ) {
2052
+ errorStack.add(
2053
+ `Incorrect type of arguments ${i} for (${
2054
+ first[VALUE]
2055
+ }). Expected (${toTypeNames(
2056
+ args[i][STATS][RETURNS][1]
2057
+ )}) but got (${toTypeNames(
2058
+ T
2059
+ )}) (${stringifyArgs(exp)}) (check #13)`
2060
+ )
2061
+ }
2062
+ }
2063
+
2064
+ if (
2065
+ env[rest[i][VALUE]] &&
2066
+ env[rest[i][VALUE]][STATS][TYPE_PROP][0] !==
2067
+ UNKNOWN &&
2068
+ args[i][STATS][TYPE_PROP][0] !== UNKNOWN &&
2069
+ env[rest[i][VALUE]][STATS][TYPE_PROP][0] !==
2070
+ args[i][STATS][TYPE_PROP][0]
2029
2071
  ) {
2030
2072
  errorStack.add(
2031
2073
  `Incorrect type of arguments ${i} for (${