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

feat: remove folding #3709

Closed
wants to merge 127 commits into from
Closed

feat: remove folding #3709

wants to merge 127 commits into from

Conversation

tserg
Copy link
Collaborator

@tserg tserg commented Dec 26, 2023

What I did

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-->

# call `fold` for its typechecking side effects`
try:
self.fold(node)
except UnfoldableNode:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
# exceptions other than `UnfoldableNode` to raise
try:
node.get_folded_value_throwing()
except UnfoldableNode:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
Comment on lines +10 to +14
from vyper.semantics.analysis.utils import (
check_modifiability,
get_exact_type_from_node,
validate_expected_type,
)

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
vyper.semantics.analysis.utils
begins an import cycle.
constants[name] = val
derived_nodes += 1
const_var_decls.remove(c)
except UnfoldableNode:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
@codecov-commenter
Copy link

codecov-commenter commented Dec 26, 2023

Codecov Report

Attention: 38 lines in your changes are missing coverage. Please review.

Comparison is base (bf26f83) 84.05% compared to head (fe925d6) 84.12%.

Files Patch % Lines
vyper/builtins/functions.py 80.29% 17 Missing and 10 partials ⚠️
vyper/ast/nodes.py 89.74% 2 Missing and 6 partials ⚠️
vyper/ast/folding.py 84.21% 2 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3709      +/-   ##
==========================================
+ Coverage   84.05%   84.12%   +0.07%     
==========================================
  Files          92       93       +1     
  Lines       13045    13160     +115     
  Branches     2925     2943      +18     
==========================================
+ Hits        10965    11071     +106     
- Misses       1654     1656       +2     
- Partials      426      433       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tserg
Copy link
Collaborator Author

tserg commented Dec 28, 2023

I ran into a few complications:

  • For literal nodes, we do not want the "folded_value" in metadata to be populated because this causes unnecessary duplication of some machinery like type-checking and type annotation. This requires the get_folded_value_maybe() and get_folded_value_throwing() to be tweaked for these nodes so that these functions return a valid node (i.e. they are literals and can be "folded") without populating the metadata.
  • The consequence is that outside of the pre-typechecking phase, we should read the folded value using node._metadata.get("folded_value") because we are now interested in whether the node should actually be replaced by another folded node, and not whether it is capable of being folded.

@tserg tserg closed this Dec 29, 2023
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.

2 participants