Skip to content

Fix ReferenceError for let/const variables in of/in for loop #3885

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

Merged
merged 1 commit into from
Jun 10, 2020

Conversation

rwalczyna
Copy link
Contributor

ReferenceError should be thrown when variable is used before assignment.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com

@rerobika rerobika requested a review from zherczeg June 9, 2020 13:09
@zherczeg
Copy link
Member

zherczeg commented Jun 9, 2020

Could you provide a simple example for the issue? I would not mind adding the test case to jerry tests as well, since if we move to another test262 hash, these tests might change.

@rwalczyna rwalczyna force-pushed the FixLetReferenceError branch from b45ac77 to 75606dd Compare June 10, 2020 05:47
@rwalczyna
Copy link
Contributor Author

You are right, test262 repository is external, so it might be changed. I have added test to es2015 directory.

@@ -2108,7 +2108,7 @@ scanner_scan_statement_end (parser_context_t *context_p, /**< context */
while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
{
if ((literal_p->type & (SCANNER_LITERAL_IS_LET | SCANNER_LITERAL_IS_CONST))
&& literal_p->type & SCANNER_LITERAL_NO_REG)
&& (literal_p->type & (SCANNER_LITERAL_NO_REG | SCANNER_LITERAL_IS_USED)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on SCAN_STACK_BINDING_INIT, I think SCANNER_LITERAL_IS_USED should be enough alone.

ReferenceError should be thrown when variable is used before assignment

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
@rwalczyna rwalczyna force-pushed the FixLetReferenceError branch from 75606dd to 6f206bb Compare June 10, 2020 07:20
Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@dbatyai dbatyai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbatyai dbatyai merged commit 049a0c4 into jerryscript-project:master Jun 10, 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.

3 participants