Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluator: Fix handling of return statements #26

Merged
merged 5 commits into from
Mar 2, 2020

Conversation

anubh-v
Copy link
Owner

@anubh-v anubh-v commented Feb 29, 2020

Previously, return statements were being evaluated but they were not treated correctly during evaluation.

Specifically, there were 2 mistakes:

  • When evaluating a sequence of statements, if a return statement is encountered, the subsequent statements should be ignored.

Example:

function foo(x) {
    return 5;
    x + 1;
}

foo(5) should return 5, not 6;

  • If the body of a function does not contain a return statement, applying that function should give the undefined value.

Example:

function foo(x) {
    x + 1;
}

foo(5) should return undefined, not 6.

@anubh-v anubh-v merged commit 342dcf9 into master Mar 2, 2020
@anubh-v anubh-v deleted the fix-return-statements branch March 2, 2020 18:09
@anubh-v anubh-v restored the fix-return-statements branch March 3, 2020 05:27
anubh-v added a commit that referenced this pull request Mar 3, 2020
anubh-v added a commit that referenced this pull request Mar 3, 2020
anubh-v added a commit that referenced this pull request Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant