depyo 1.2.4 → 1.2.5
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.
- package/lib/ast/ast_node.js +22 -2
- package/package.json +1 -1
package/lib/ast/ast_node.js
CHANGED
|
@@ -1120,10 +1120,30 @@ class ASTStore extends ASTNode {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
}
|
|
1122
1122
|
|
|
1123
|
-
let methodBody = codeObject.SourceCode.codeFragment();
|
|
1124
1123
|
if (inLambda) {
|
|
1125
|
-
|
|
1124
|
+
// issue #12: lambda body must render as an expression. Going
|
|
1125
|
+
// through ASTNodeList.codeFragment would emit "pass" for a single
|
|
1126
|
+
// `return None` (emptyBlock heuristic) and crash on a truly empty
|
|
1127
|
+
// body (3.12/3.13 RETURN_CONST None). Render the single ASTReturn
|
|
1128
|
+
// directly via its inLambda path; fall back to "None".
|
|
1129
|
+
const stmts = (codeObject.SourceCode?.list || []).filter(n => n);
|
|
1130
|
+
if (stmts.length === 1 && stmts[0] instanceof ASTReturn) {
|
|
1131
|
+
stmts[0].inLambda = true;
|
|
1132
|
+
const frag = stmts[0].codeFragment();
|
|
1133
|
+
const body = (frag && frag.toString().trim()) || "None";
|
|
1134
|
+
result.lastLineAppend(body);
|
|
1135
|
+
} else if (stmts.length > 0) {
|
|
1136
|
+
const methodBody = codeObject.SourceCode.codeFragment();
|
|
1137
|
+
if (methodBody && methodBody.toString().trim()) {
|
|
1138
|
+
result.lastLineAppend(methodBody);
|
|
1139
|
+
} else {
|
|
1140
|
+
result.lastLineAppend("None");
|
|
1141
|
+
}
|
|
1142
|
+
} else {
|
|
1143
|
+
result.lastLineAppend("None");
|
|
1144
|
+
}
|
|
1126
1145
|
} else {
|
|
1146
|
+
let methodBody = codeObject.SourceCode.codeFragment();
|
|
1127
1147
|
const bodyHasContent = methodBody && methodBody.toString().trim().length;
|
|
1128
1148
|
const hasGlobals = codeObject.Globals && codeObject.Globals.size > 0;
|
|
1129
1149
|
if (bodyHasContent) {
|