fez-lisp 1.3.5 → 1.3.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/interpreter.js +12 -6
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.3.5",
5
+ "version": "1.3.6",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
@@ -147,20 +147,26 @@ export const keywords = {
147
147
  return a % b
148
148
  },
149
149
  [KEYWORDS.BITWISE_AND]: (args, env) => {
150
- if (args.length < 2)
150
+ if (args.length !== 2)
151
151
  throw new RangeError(
152
152
  `Invalid number of arguments to (${
153
153
  KEYWORDS.BITWISE_AND
154
154
  }) (= 2 required). (${KEYWORDS.BITWISE_AND} ${stringifyArgs(args)})`
155
155
  )
156
- const operands = args.map((a) => evaluate(a, env))
157
- if (operands.some((x) => typeof x !== 'number'))
156
+ if (typeof a !== 'number')
157
+ throw new TypeError(
158
+ `First arguments of (${KEYWORDS.BITWISE_AND}) is not a (${
159
+ RUNTIME_TYPES.NUMBER
160
+ }) (${KEYWORDS.BITWISE_AND} ${stringifyArgs(args)})`
161
+ )
162
+ const b = evaluate(args[1], env)
163
+ if (typeof b !== 'number')
158
164
  throw new TypeError(
159
- `Not all arguments of (${KEYWORDS.BITWISE_AND}) are ${
165
+ `Second arguments of (${KEYWORDS.BITWISE_AND}) is not a (${
160
166
  RUNTIME_TYPES.NUMBER
161
- } (${KEYWORDS.BITWISE_AND} ${stringifyArgs(args)})`
167
+ }) (${KEYWORDS.BITWISE_AND} ${stringifyArgs(args)})`
162
168
  )
163
- return operands.reduce((acc, x) => acc & x)
169
+ return a & b
164
170
  },
165
171
  [KEYWORDS.BITWISE_NOT]: (args, env) => {
166
172
  if (args.length !== 1)