fez-lisp 1.5.39 → 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
@@ -10,12 +10,13 @@ import {
10
10
  FALSE,
11
11
  KEYWORDS,
12
12
  PLACEHOLDER,
13
+ PREDICATE_SUFFIX,
13
14
  TRUE,
14
15
  TYPE,
15
16
  VALUE,
16
17
  WORD
17
18
  } from './keywords.js'
18
- import { hasBlock, stringifyArgs } from './utils.js'
19
+ import { getSuffix, hasBlock, stringifyArgs } from './utils.js'
19
20
  export const SUGGAR = {
20
21
  // Syntactic suggars
21
22
  PIPE: '|>',
@@ -523,6 +524,11 @@ export const deSuggarAst = (ast, scope) => {
523
524
  const name = exp[1][VALUE]
524
525
  const prefix = name.split(':')[0]
525
526
  if (prefix === OPTIMIZATIONS.RECURSION) {
527
+ if (getSuffix(name) === PREDICATE_SUFFIX) {
528
+ throw new TypeError(
529
+ `Optimized (lambda) ${name} can't be a (Predicate) as it will return a (lambda). Remove the (${PREDICATE_SUFFIX}) from the name`
530
+ )
531
+ }
526
532
  const args = last.slice(1, -1)
527
533
  const newName = `*${performance
528
534
  .now()
@@ -619,6 +625,11 @@ export const deSuggarAst = (ast, scope) => {
619
625
  ]
620
626
  deSuggarAst(exp[exp.length - 1])
621
627
  } else if (prefix === OPTIMIZATIONS.CACHE) {
628
+ if (getSuffix(name) === PREDICATE_SUFFIX) {
629
+ throw new TypeError(
630
+ `Optimized (lambda) ${name} can't be a (Predicate) as it will return a (lambda). Remove the (${PREDICATE_SUFFIX}) from the name`
631
+ )
632
+ }
622
633
  const args = last.slice(1, -1)
623
634
  const newName = `*${performance
624
635
  .now()
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, '')