author | Alan Dipert
<alan@dipert.org> 2020-01-30 01:06:14 UTC |
committer | Alan Dipert
<alan@dipert.org> 2020-01-30 01:06:14 UTC |
parent | 3466be97b6514b87c3c5e59eba92314c5a376c9d |
jacl.js | +10 | -5 |
diff --git a/jacl.js b/jacl.js index 80576a0..96828d8 100644 --- a/jacl.js +++ b/jacl.js @@ -1939,11 +1939,16 @@ const emitNode = (print, node) => { if (context !== 'expr') print(';\n'); break; } case 'progn': { - if (context === 'expr') print('(function()'); - print('{'); - emitBlock(print, node.statements, node.ret); - print('}'); - if (context === 'expr') print(')()'); + if (context === 'expr' && !node.statements.length) { + // If there's only a return expression, just emit that. + emitNode(print, merge(node.ret, { env: node.ret.env.withContext('expr') })); + } else { + if (context === 'expr') print('(function()'); + print('{'); + emitBlock(print, node.statements, node.ret); + print('}'); + if (context === 'expr') print(')()'); + } break; } default: throw new Error(`Unknown op: ${op}`);