Skip to content

Commit

Permalink
Fix for simple returns in functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wisec committed Dec 14, 2018
1 parent 0295813 commit c6c85d7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/jstiller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ var jstiller = (function() {
} else {
calleeBody.retVal = mkliteral(calleeBody.value);
}
} else if ( /*EXPERIMENTAL!*/ calleeBody && calleeBody.body && calleeBody.body.length === 1 && calleeBody.scope.hasOwnProperty("returns")
} else if ( /*EXPERIMENTAL!*/ calleeBody && calleeBody.body && calleeBody.body.length === 1 && calleeBody.body[0].argument && calleeBody.scope.hasOwnProperty("returns")
&& calleeBody.scope.returns === 1) {
//TODO We need to copy the function scope and add params values!! tmp_scope = Object.create(calleBody.scope)
// Copy all values.
Expand Down Expand Up @@ -2858,6 +2858,9 @@ var jstiller = (function() {

case 'ReturnStatement':
debug('ReturnStatement');
if(ast.argument==null){
return ast;
}
value = ast_reduce(ast.argument, scope, true, ast);
scope.returns = scope.hasOwnProperty("returns") ? ++scope.returns : 1;

Expand Down

0 comments on commit c6c85d7

Please sign in to comment.