fez-lisp 1.5.106 → 1.5.108

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.106",
5
+ "version": "1.5.108",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/check.js CHANGED
@@ -346,7 +346,7 @@ const ifExpression = ({ re, env, ref, prop }) => {
346
346
  // TODO make this more simple - it's so many different things just because types are functions or not
347
347
  // WHY not consiter making return types for everything
348
348
  if (concequent)
349
- if (conc[TYPE] === WORD && conc[VALUE] !== NIL) {
349
+ if (conc[TYPE] === WORD) {
350
350
  return setPropToTypeRef(ref[STATS], prop, concequent[STATS])
351
351
  } else if (
352
352
  conc[TYPE] === APPLY &&
@@ -364,7 +364,7 @@ const ifExpression = ({ re, env, ref, prop }) => {
364
364
  })
365
365
  }
366
366
  if (alternative) {
367
- if (alt[TYPE] === WORD && alt[VALUE] !== NIL) {
367
+ if (alt[TYPE] === WORD) {
368
368
  return setPropToTypeRef(ref[STATS], prop, alternative[STATS])
369
369
  } else if (
370
370
  alt[TYPE] === APPLY &&
package/src/macros.js CHANGED
@@ -122,11 +122,11 @@ export const deSuggarAst = (ast, scope) => {
122
122
  break
123
123
  case SUGGAR.CONDITION:
124
124
  {
125
- if (rest.length < 2)
125
+ if (rest.length < 4)
126
126
  throw new RangeError(
127
127
  `Invalid number of arguments for (${
128
128
  SUGGAR.CONDITION
129
- }), expected (> 2 required) but got ${rest.length} (${
129
+ }), expected (> 3 required) but got ${rest.length} (${
130
130
  SUGGAR.CONDITION
131
131
  } ${stringifyArgs(rest)})`
132
132
  )
@@ -138,11 +138,25 @@ export const deSuggarAst = (ast, scope) => {
138
138
  rest.length
139
139
  } (${SUGGAR.CONDITION} ${stringifyArgs(rest)})`
140
140
  )
141
+ if (rest.at(-2)[0][VALUE] !== KEYWORDS.MULTIPLICATION) {
142
+ throw new ReferenceError(
143
+ `Last condition of (${
144
+ SUGGAR.CONDITION
145
+ }), has to be a wildcard (${KEYWORDS.MULTIPLICATION}) (${
146
+ SUGGAR.CONDITION
147
+ }) followed by a default result (${stringifyArgs(exp)}))`
148
+ )
149
+ }
141
150
  exp.length = 0
142
151
  let temp = exp
143
152
  for (let i = 0; i < rest.length; i += 2) {
144
153
  if (i === rest.length - 2) {
145
- temp.push([APPLY, KEYWORDS.IF], rest[i], rest.at(-1))
154
+ temp.push(
155
+ [APPLY, KEYWORDS.IF],
156
+ rest[i],
157
+ rest.at(-1),
158
+ rest.at(-1)
159
+ )
146
160
  } else {
147
161
  temp.push([APPLY, KEYWORDS.IF], rest[i], rest[i + 1], [])
148
162
  temp = temp.at(-1)