rip-lang 3.13.113 → 3.13.115

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "3.13.113",
3
+ "version": "3.13.115",
4
4
  "description": "A modern language that compiles to JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
package/src/compiler.js CHANGED
@@ -1116,10 +1116,12 @@ export class CodeGenerator {
1116
1116
  let isAsync = this.containsAwait(body);
1117
1117
  let prefix = isAsync ? 'async ' : '';
1118
1118
 
1119
+ let stmtOnly = new Set(['def', 'class', 'if', 'for-in', 'for-of', 'for-as', 'while', 'until', 'loop', 'switch', 'try', 'unless']);
1119
1120
  if (!sideEffectOnly) {
1120
1121
  if (this.is(body, 'block') && body.length === 2) {
1121
1122
  let expr = body[1];
1122
- if (!Array.isArray(expr) || expr[0] !== 'return') {
1123
+ let exprHead = Array.isArray(expr) ? expr[0] : null;
1124
+ if (exprHead !== 'return' && !stmtOnly.has(exprHead)) {
1123
1125
  let code = this.generate(expr, 'value');
1124
1126
  if (code[0] === '{') code = `(${code})`;
1125
1127
  return `${prefix}${paramSyntax} => ${code}`;