Skip to content

Commit 313339c

Browse files
committed
feat: refactor return statement to assign function result to variable before returning
1 parent 9aab9c2 commit 313339c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ export function generateFlowSourceCode(
155155
let code = `${indent}`;
156156

157157
if (node.functionDefinition.identifier === "std::control::return") {
158-
code += `return /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n`
158+
code += `const ${varName} = /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n`
159+
code += `return ${varName};\n`
159160
} else if (node.functionDefinition.identifier === "std::control::if") {
160161
code += `const ${varName} = /* @pos ${id} null */ ${funcName}(${args.join(", ")})${needsAnyCast ? "" : ""} ;\n`
161162
code += `if(${args[0]}) {

0 commit comments

Comments
 (0)