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: add ternary operator #3398

Merged
merged 9 commits into from
May 11, 2023

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented May 10, 2023

What I did

fix #3055

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

vyper/codegen/expr.py Fixed Show fixed Hide fixed
vyper/codegen/expr.py Fixed Show fixed Hide fixed
@codecov-commenter
Copy link

codecov-commenter commented May 10, 2023

Codecov Report

Merging #3398 (422442c) into master (d9e376c) will increase coverage by 0.04%.
The diff coverage is 88.88%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #3398      +/-   ##
==========================================
+ Coverage   88.92%   88.96%   +0.04%     
==========================================
  Files          86       86              
  Lines       10726    10760      +34     
  Branches     2440     2443       +3     
==========================================
+ Hits         9538     9573      +35     
- Misses        787      788       +1     
+ Partials      401      399       -2     
Impacted Files Coverage Δ
vyper/semantics/analysis/annotation.py 87.63% <60.00%> (-1.64%) ⬇️
vyper/ast/nodes.py 94.24% <100.00%> (+0.01%) ⬆️
vyper/codegen/expr.py 87.94% <100.00%> (+0.35%) ⬆️
vyper/semantics/analysis/local.py 91.90% <100.00%> (+0.09%) ⬆️
vyper/semantics/analysis/utils.py 92.33% <100.00%> (+0.20%) ⬆️

... and 2 files with indirect coverage changes

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

@charles-cooper charles-cooper marked this pull request as ready for review May 10, 2023 17:25
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

Moar test cases, but looks solid

in case we ever use custom grammar or something
@charles-cooper charles-cooper enabled auto-merge (squash) May 11, 2023 18:49
@charles-cooper charles-cooper merged commit 51e1316 into vyperlang:master May 11, 2023
Copy link
Collaborator

@pcaversaccio pcaversaccio left a comment

Choose a reason for hiding this comment

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

We should maybe add a nested test as well. I plan to use nested ternary operators in my Merkle multiproof contract here:

b = (leaves[leaf_pos] if leaf_pos < leaves_length else hashes[hash_pos]) if flag else proof[proof_pos]

@charles-cooper
Copy link
Member Author

We should maybe add a nested test as well. I plan to use nested ternary operators in my Merkle multiproof contract here:

b = (leaves[leaf_pos] if leaf_pos < leaves_length else hashes[hash_pos]) if flag else proof[proof_pos]

It's right here: https://github.com/vyperlang/vyper/pull/3398/files#diff-59aca5215be5acc4bc64451f64da58d8a2e777bd306a104dfa07a0db6ca34771R237

@charles-cooper charles-cooper deleted the feat/ternary branch May 11, 2023 21:39
@pcaversaccio
Copy link
Collaborator

Oh missed that one - awesome!

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.

VIP: Ternary operator
4 participants