Skip to content

Commit 9fcb1c3

Browse files
authored
Merge pull request #107 from JohanWiltink/main
allow for nullish JS values as expressions
2 parents b89b755 + 79dd1d9 commit 9fcb1c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lambda-calculus.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class L {
4242
this.body = body;
4343
}
4444
free() {
45-
const r = this.body.free?.() || new Set ;
45+
const r = this.body?.free?.() || new Set ;
4646
r.delete(this.name);
4747
return r;
4848
}
@@ -58,7 +58,7 @@ class A {
5858
this.left = left;
5959
this.right = right;
6060
}
61-
free() { return union( this.left.free?.() || [] , this.right.free?.() || [] ); }
61+
free() { return union( this.left?.free?.() || [] , this.right?.free?.() || [] ); }
6262
toString() {
6363
const left = this.left instanceof L ? `(${this.left})` : this.left ;
6464
const right = this.right instanceof V ? this.right : `(${this.right})` ;
@@ -169,7 +169,7 @@ export function toInt(term) {
169169
function parse(code) {
170170
function parseTerm(env,code) {
171171
function wrap(name,term) {
172-
const FV = term.free?.() || new Set ; FV.delete("()");
172+
const FV = term?.free?.() || new Set ; FV.delete("()");
173173
if ( config.purity === "Let" )
174174
return Array.from(FV).reduce( (tm,nm) => {
175175
if ( env.has(nm) ) {

0 commit comments

Comments
 (0)