diff --git a/build-aux/bootstrap/prebirth.js b/build-aux/bootstrap/prebirth.js index 3508338..a11fdd0 100644 --- a/build-aux/bootstrap/prebirth.js +++ b/build-aux/bootstrap/prebirth.js @@ -543,10 +543,13 @@ class Compiler const fnmap = { 'js:console': 'console.log', - // simple if statement with optional else + // simple if statement with optional else, wrapped in a self-executing + // function to simplify code generation (e.g. returning an if) 'if': ( [ pred, t, f ], stoes ) => - `if (${stoes(pred)}) {${stoes(t)};} ` + - ( ( f === undefined ) ? '' : `else {${stoes(f)};}` ), + "(function(){" + + `if (${stoes(pred)}){return ${stoes(t)};}` + + ( ( f === undefined ) ? '' : `else{return ${stoes(f)};}` ) + + "})()", // (let ((binding val) ...) ...body), compiled as a self-executing // function which allows us to easily represent the return value of the