diff --git a/wcprogram.js b/wcprogram.js index a96a3de..baa3eec 100644 --- a/wcprogram.js +++ b/wcprogram.js @@ -237,6 +237,8 @@ class WCProgram extends HTMLElement { .filter(Boolean).map(s => s + "\n").join("") : ""; + const hasReturnOrExit = + body.includes("\n return ") || body.includes("\n exit("); const raw = "// --- WiseCode\u00ae ---\n" + (includes ? includes + "\n\n" : "") + @@ -244,7 +246,7 @@ class WCProgram extends HTMLElement { (typeDefs ? typeDefs + "\n\n" : "") + (unitDefs ? unitDefs + "\n\n" : "") + stringStruct + dataSection + body + - "return 0;\n" + + (hasReturnOrExit ? "" : "return 0;\n") + "}\n// --- END ---"; outputEl.textContent = raw; if (typeof hljs !== "undefined") hljs.highlightElement(outputEl);