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

Fixed bug in for loops #1734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed bug in for loops #1734

wants to merge 1 commit into from

Conversation

chuckyang123
Copy link

Description

changes initialisation in for loops to fit Source specification as per #1727

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How to test

let y=0;
for (let i=(y=y+1);i<=1;i=i+1){
display(i);
}
now runs through a loop and display 1 instead of undefined

Checklist

  • I have tested this code

@@ -584,14 +584,14 @@ const cmdEvaluators: { [type: string]: CmdEvaluator } = {
// Refer to Source §3 specifications https://docs.sourceacademy.org/source_3.pdf
if (init.type === 'VariableDeclaration' && init.kind === 'let') {
const id = init.declarations[0].id as es.Identifier
const valueExpression = init.declarations[0].init!
// const valueExpression = init.declarations[0].init!
Copy link
Member

Choose a reason for hiding this comment

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

Let's try to not leave commented code around. If it's unused, remove it entirely, and if it's only unused for now, leave another comment explaining why.

@alsonleej alsonleej requested a review from s-kybound February 12, 2025 10:07
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