fez-lisp 1.5.40 → 1.5.41

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/src/macros.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  VALUE,
17
17
  WORD
18
18
  } from './keywords.js'
19
- import { hasBlock, stringifyArgs } from './utils.js'
19
+ import { getSuffix, hasBlock, stringifyArgs } from './utils.js'
20
20
  export const SUGGAR = {
21
21
  // Syntactic suggars
22
22
  PIPE: '|>',
@@ -524,7 +524,7 @@ export const deSuggarAst = (ast, scope) => {
524
524
  const name = exp[1][VALUE]
525
525
  const prefix = name.split(':')[0]
526
526
  if (prefix === OPTIMIZATIONS.RECURSION) {
527
- if (name[name.length - 1] === PREDICATE_SUFFIX) {
527
+ if (getSuffix(name) === PREDICATE_SUFFIX) {
528
528
  throw new TypeError(
529
529
  `Optimized (lambda) ${name} can't be a (Predicate) as it will return a (lambda). Remove the (${PREDICATE_SUFFIX}) from the name`
530
530
  )
@@ -625,7 +625,7 @@ export const deSuggarAst = (ast, scope) => {
625
625
  ]
626
626
  deSuggarAst(exp[exp.length - 1])
627
627
  } else if (prefix === OPTIMIZATIONS.CACHE) {
628
- if (name[name.length - 1] === PREDICATE_SUFFIX) {
628
+ if (getSuffix(name) === PREDICATE_SUFFIX) {
629
629
  throw new TypeError(
630
630
  `Optimized (lambda) ${name} can't be a (Predicate) as it will return a (lambda). Remove the (${PREDICATE_SUFFIX}) from the name`
631
631
  )
package/src/utils.js CHANGED
@@ -19,6 +19,7 @@ export const formatCallstack = (callstack) =>
19
19
  export const formatErrorWithCallstack = (error, callstack) => {
20
20
  return `${error.message}\n${formatCallstack(callstack)}`
21
21
  }
22
+ export const getSuffix = (str) => str[str.length - 1]
22
23
  export const removeNoCode = (source) =>
23
24
  source
24
25
  .replace(/(;.+|;)/g, '')