Skip to content

fix[lang]: fix == and != bytesM folding#4254

Merged
charles-cooper merged 3 commits intovyperlang:masterfrom
trocher:fix/bytes_folding
Sep 26, 2024
Merged

fix[lang]: fix == and != bytesM folding#4254
charles-cooper merged 3 commits intovyperlang:masterfrom
trocher:fix/bytes_folding

Conversation

@trocher
Copy link
Copy Markdown
Contributor

@trocher trocher commented Sep 23, 2024

What I did

Fix [bytesN] [==|!=] [bytesN] to be folded as the operation was computed on python strings and not integer values.

How I did it

Compare lowercase strings instead of strings to be case-insensitive.

How to verify it

The test is explicit.

Before this, the following would hold.

@external
def foo() -> bool:
    a:bytes4 = 0xA1AAB33F
    b:bytes4 = 0xa1aab33f
    return a == b # returns True

@external
def bar() -> bool:
    return 0xA1AAB33F == 0xa1aab33f # returns False

Commit message

`bytesM` literals are not case-sensitive (they represent the same value
no matter if the literal is lower- or upper-case), but the folding
operation was case sensitive.

Description for the changelog

fix == and != bytes folding

Cute Animal Picture

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

@trocher trocher changed the title fix[lang]: prevent eq/neq bytes folding fix[lang]: fix == and != bytes folding Sep 23, 2024
@charles-cooper charles-cooper changed the title fix[lang]: fix == and != bytes folding fix[lang]: fix == and != bytesM folding Sep 26, 2024
@charles-cooper charles-cooper merged commit d60d31f into vyperlang:master Sep 26, 2024
charles-cooper added a commit to charles-cooper/vyper that referenced this pull request Oct 5, 2024
`bytesM` literals are not case-sensitive (they represent the same value
no matter if the literal is lower- or upper-case), but the folding
operation was case sensitive.

---------

Co-authored-by: Charles Cooper <[email protected]>
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