Skip to content

Commit 814332d

Browse files
author
Neil Fraser
committed
Return undefined from functions by default.
1 parent 21438b4 commit 814332d

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Apache License
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2014 Neil Fraser
189+
Copyright 2013 Google Inc.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.
@@ -199,4 +199,3 @@ Apache License
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201201
limitations under the License.
202-

acorn_interpreter.js

100644100755
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

interpreter.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,7 @@ Interpreter.prototype['stepCallExpression'] = function() {
15701570
thisExpression: state.funcThis_
15711571
};
15721572
this.stateStack.unshift(funcState);
1573+
state.value = this.UNDEFINED; // Default value if no explicit return.
15731574
} else if (state.func_.nativeFunc) {
15741575
state.value = state.func_.nativeFunc.apply(state.funcThis_,
15751576
state.arguments);
@@ -1894,7 +1895,7 @@ Interpreter.prototype['stepReturnStatement'] = function() {
18941895
state.done = true;
18951896
this.stateStack.unshift({node: node.argument});
18961897
} else {
1897-
var value = state.value; // Possibly undefined.
1898+
var value = state.value || this.UNDEFINED;
18981899
do {
18991900
this.stateStack.shift();
19001901
if (this.stateStack.length == 0) {

0 commit comments

Comments
 (0)