From 4324641c18eb328c0522a28381c9921c7e97da29 Mon Sep 17 00:00:00 2001 From: Johan Wiltink Date: Fri, 26 Jan 2024 04:08:04 +0100 Subject: [PATCH] fix `.free` calls in `L` and `wrap` allow for JS values as abstraction bodies and expressions ( number literals in custom encoding ) --- src/lambda-calculus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lambda-calculus.js b/src/lambda-calculus.js index 6e08e5d..f5affe1 100644 --- a/src/lambda-calculus.js +++ b/src/lambda-calculus.js @@ -42,7 +42,7 @@ class L { this.body = body; } free() { - const r = this.body.free(); + const r = this.body.free?.() || new Set ; r.delete(this.name); return r; } @@ -169,7 +169,7 @@ export function toInt(term) { function parse(code) { function parseTerm(env,code) { function wrap(name,term) { - const FV = term.free(); FV.delete("()"); + const FV = term.free?.() || new Set ; FV.delete("()"); if ( config.purity === "Let" ) return Array.from(FV).reduce( (tm,nm) => { if ( env.has(nm) ) {