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: rewrite typechecker journal to handle nested commits #3375

Merged

Conversation

charles-cooper
Copy link
Member

What I did

fix #3374

How I did it

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov-commenter
Copy link

codecov-commenter commented Apr 29, 2023

Codecov Report

Merging #3375 (20b2bb0) into master (0c7066c) will decrease coverage by 0.05%.
The diff coverage is 94.23%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #3375      +/-   ##
==========================================
- Coverage   88.85%   88.80%   -0.05%     
==========================================
  Files          84       85       +1     
  Lines       10673    10706      +33     
  Branches     2226     2233       +7     
==========================================
+ Hits         9483     9507      +24     
- Misses        789      798       +9     
  Partials      401      401              
Impacted Files Coverage Δ
vyper/semantics/analysis/__init__.py 100.00% <ø> (ø)
vyper/semantics/analysis/utils.py 92.13% <ø> (-0.33%) ⬇️
vyper/ast/metadata.py 93.47% <93.47%> (ø)
vyper/ast/nodes.py 94.22% <100.00%> (+<0.01%) ⬆️
vyper/semantics/analysis/local.py 91.78% <100.00%> (ø)

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more


@classmethod
@contextlib.contextmanager
def speculate(cls):
Copy link
Member

Choose a reason for hiding this comment

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

Kind of a weird function name, maybe analyze or validate

Copy link
Member Author

@charles-cooper charles-cooper May 1, 2023

Choose a reason for hiding this comment

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

it enters a stateful transaction which could be rolled back, so it would be something like speculate(), or a more vanilla(!) name would be enter() or begin_transaction()

Copy link
Member

Choose a reason for hiding this comment

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

From the point of view of the compilation, or runtime?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a compile time stateful transaction on the ast. I just realized I still need to write the PR notes.

Copy link
Member

Choose a reason for hiding this comment

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

The naming doesn't make that totally clear to me, at a quick glance

Copy link
Member Author

@charles-cooper charles-cooper May 2, 2023

Choose a reason for hiding this comment

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

i renamed to enter_typechecker_speculation. it's a bit long-winded but it seems descriptive enough to me and invites the reader to take a closer look (which they should! as this is a complicated operation going on.)

this commit fixes a bug which was introduced in 66930fd. when the
typechecker enters a nested loop, it can typecheck the inner loop
(committing it), and result in invalid state if the outer loop fails to
typecheck. this commit implements a checkpointing system in the
typechecker state committer so that it can handle nested changes. it
also cleans up the data structure used so that there is a single entry
point and users of the data structure do not need to think about
implementation details.

one drawback of this approach is that it can *only* handle changes to
the metadata dict. non-idempotent changes to the AST during typechecking
should then be restricted to changes to the metadata dict so that they
can register automatically with the node metadata journal.
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.

typechecker state committer has incorrect behavior for nested loops
3 participants