-
Notifications
You must be signed in to change notification settings - Fork 77
feat(sema): implicit bytes literal conversion to bytes dynamic/fixed #642
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
Open
dipanshuhappy
wants to merge
9
commits into
paradigmxyz:main
Choose a base branch
from
dipanshuhappy:feat/implicit-bytes-conversion
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−0
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f0266a6
feat(sema): enum explicit conversion
dipanshuhappy 47e957e
chore(sema): updated clippy format
dipanshuhappy a3ae220
Merge branch 'paradigmxyz:main' into main
dipanshuhappy cd3a2a9
Merge branch 'paradigmxyz:main' into main
dipanshuhappy 99531d5
feat(sema): allow implicit conversion from string literals to bytes
dipanshuhappy 3d3d014
docs(sema): updated docs for implicit conversion
dipanshuhappy 448cf6a
feat(sema): added test cases for implicit bytes
dipanshuhappy e2fb66f
Merge branch 'main' into feat/implicit-bytes-conversion
dipanshuhappy a9093a5
feat(sema): updated with proper semantic type error
dipanshuhappy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //@compile-flags: -Ztypeck | ||
| contract C { | ||
| function f() public pure { | ||
| // --- Valid: literal to fixed-size bytes (equal size) --- | ||
| bytes3 b3_1 = "abc"; | ||
| bytes3 b3_2 = hex"123456"; | ||
|
|
||
| // --- Valid: literal to fixed-size bytes (larger size) --- | ||
| bytes10 b10_1 = "abc"; | ||
| bytes10 b10_2 = hex"123456"; | ||
|
|
||
| // --- Invalid: literal to fixed-size bytes (smaller size) --- | ||
| bytes2 invalid_b2 = "abc"; //~ ERROR: mismatched types | ||
| bytes2 invalid_h2 = hex"123456"; //~ ERROR: mismatched types | ||
| bytes1 invalid_b1 = "ab"; //~ ERROR: mismatched types | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| error: mismatched types | ||
| ╭▸ ROOT/tests/ui/typeck/literal_bytes_implicit_conversion.sol:LL:CC | ||
| │ | ||
| LL │ bytes2 invalid_b2 = "abc"; | ||
| ╰╴ ━━━━━ cannot convert `utf8_string_literal[3]` to `bytes2` | ||
|
|
||
| error: mismatched types | ||
| ╭▸ ROOT/tests/ui/typeck/literal_bytes_implicit_conversion.sol:LL:CC | ||
| │ | ||
| LL │ bytes2 invalid_h2 = hex"123456"; | ||
| ╰╴ ━━━━━━━━━━━ cannot convert `utf8_string_literal[3]` to `bytes2` | ||
|
|
||
| error: mismatched types | ||
| ╭▸ ROOT/tests/ui/typeck/literal_bytes_implicit_conversion.sol:LL:CC | ||
| │ | ||
| LL │ bytes1 invalid_b1 = "ab"; | ||
| ╰╴ ━━━━ cannot convert `utf8_string_literal[2]` to `bytes1` | ||
|
|
||
| error: aborting due to 3 previous errors | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a new variant to match the solc error message?