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

Fix env viz import issues #1451

Merged
merged 7 commits into from
Jul 27, 2023
Merged

Fix env viz import issues #1451

merged 7 commits into from
Jul 27, 2023

Conversation

tsinyee
Copy link
Contributor

@tsinyee tsinyee commented Jul 21, 2023

ImportDeclarations are now handled in the Program evaluator in cmdEvaluators so that all toplevel names are shown right away in the program environment - Fixes #1450
ImportDeclarations are now non value producing - Fixes #1448 (POP issue)
Screenshot 2023-07-21 at 7 46 53 PM

Added a condition in runECEMachine to check if the command is an ImportDeclaration, then the current step is not incremented - Fixes #1448 (redundant steps issue but this feels quite hackish? )
Screenshot 2023-07-21 at 7 47 13 PM

@tsinyee tsinyee requested a review from martin-henz July 21, 2023 11:53
@coveralls
Copy link

coveralls commented Jul 21, 2023

Pull Request Test Coverage Report for Build 5677180723

  • 33 of 35 (94.29%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 83.608%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ec-evaluator/interpreter.ts 21 23 91.3%
Totals Coverage Status
Change from base Build 5596152293: 0.04%
Covered Lines: 10656
Relevant Lines: 12338

💛 - Coveralls

command = agenda.peek()
steps += 1
// If command is an ImportDeclaration, don't add unnecessary step
if (!isImportDeclaration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that this seems a bit hacky, and also feels a bit like its going against the concept of the agenda. Another problem with this is that at step 2 (in the screenshot) the user thinks that the import statement is being evaluated, but in step 3, another command is evaluated instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: In 'Program' when the block is decomposed into individual statements and pushed onto the agenda, don't push any import statements since the imports are already evaluated in 'Program'. (I would think modifying the 'handleSequence' function appropriately would work best). Then we wouldn't need this hack since our evaluator won't encounter any import statements.

Copy link
Contributor

Choose a reason for hiding this comment

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

Rest looks good to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggestion: In 'Program' when the block is decomposed into individual statements and pushed onto the agenda, don't push any import statements since the imports are already evaluated in 'Program'. (I would think modifying the 'handleSequence' function appropriately would work best). Then we wouldn't need this hack since our evaluator won't encounter any import statements.

this means that the import statements won't be in the agenda at all?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep! The user can see the import statements initially in the program block, but since the import statements are evaluated in the program block itself it doesn't seem to make sense to continue to push the import statements on the agenda since they do nothing and only add to confusion.
Do you agree prof? @martin-henz

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree. The handling of the program needs to create the program environment which will include the imported names and the newly declared names. The imported names can be immediately assigned to their implementation without the need of executing a step in the machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, i have made the necessary changes to the handleSequence function so the import statements are only in the program block but not on the agenda

Screenshot 2023-07-27 at 2 39 03 PM Screenshot 2023-07-27 at 2 39 43 PM

@tsinyee tsinyee requested a review from vansh284 July 27, 2023 06:41
Copy link
Contributor

@vansh284 vansh284 left a comment

Choose a reason for hiding this comment

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

LGTM!

@martin-henz martin-henz merged commit a8b7263 into master Jul 27, 2023
1 check passed
@martin-henz martin-henz deleted the env-viz-import-issues branch July 27, 2023 09:19
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.

Env Viz: order of declaration in Program environment Env Viz: Import statements handled inconsistently
4 participants