From 7451defb60bb283b0a1f61bafe47f1f769b58ccd Mon Sep 17 00:00:00 2001 From: Adrien Jaguenet Date: Tue, 23 Jun 2026 01:19:53 +0200 Subject: [PATCH] fix: double return 0 in generated C output - wcprogram.js.generateCode now checks if the body already contains a return or exit statement before appending the hardcoded return 0; This eliminates the duplicate return 0 from the END block. --- wcprogram.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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);