aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-18 15:23:34 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-18 15:23:34 -0800
commitc39afee38bb49a6fce996bbd276065f2f5603178 (patch)
tree0eb477a3107f1784bd830429ee1859a87cd5169f /src
parent528799c0d925fd03231a876fc38bb8398f92c81e (diff)
add return in functions whose types return but do not actually return
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index a575ea95..f767b6ce 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -797,10 +797,10 @@ function JSify(data, functionsOnly, givenFunctions) {
func.JS += walkBlock(func.block, ' ');
// Finalize function
if (LABEL_DEBUG && functionNameFilterTest(func.ident)) func.JS += " INDENT = INDENT.substr(0, INDENT.length-2);\n";
- // Add an unneeded return, needed for strict mode to not throw warnings in some cases.
- // If we are not relooping, then switches make it unimportant to have this (and, we lack hasReturn anyhow)
- if (RELOOP && func.lines.length > 0 && func.labels.filter(function(label) { return label.hasReturn }).length > 0) {
- func.JS += ' return' + (func.returnType !== 'void' ? ' null' : '') + ';\n';
+ // Ensure a return in a function with a type that returns, even if it lacks a return (e.g., if it aborts())
+ if (RELOOP && func.lines.length > 0 && func.returnType != 'void') {
+ var returns = func.labels.filter(function(label) { return label.lines[label.lines.length-1].intertype == 'return' }).length;
+ if (returns == 0) func.JS += ' return ' + asmCoercion('0', func.returnType);
}
func.JS += '}\n';