-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
String slices #4996
Merged
Merged
String slices #4996
Conversation
This file contains 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
xunilrj
force-pushed
the
xunilrj/str
branch
2 times, most recently
from
August 30, 2023 12:56
0068573
to
9a2b7fa
Compare
xunilrj
force-pushed
the
xunilrj/str
branch
3 times, most recently
from
September 6, 2023 11:46
76402e1
to
94db2d9
Compare
anton-trunov
reviewed
Sep 6, 2023
test/src/e2e_vm_tests/test_programs/should_fail/raw_slice_ret/test.toml
Outdated
Show resolved
Hide resolved
test/src/e2e_vm_tests/test_programs/should_fail/str_slice_contract/Forc.lock
Outdated
Show resolved
Hide resolved
test/src/e2e_vm_tests/test_programs/should_fail/str_slice_contract/Forc.toml
Outdated
Show resolved
Hide resolved
...2e_vm_tests/test_programs/should_pass/language/main_args/main_args_various_types/src/main.sw
Outdated
Show resolved
Hide resolved
test/src/e2e_vm_tests/test_programs/should_pass/language/str_slice/Forc.lock
Outdated
Show resolved
Hide resolved
sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
Outdated
Show resolved
Hide resolved
anton-trunov
reviewed
Sep 7, 2023
sway-core/src/semantic_analysis/ast_node/expression/intrinsic_function.rs
Outdated
Show resolved
Hide resolved
anton-trunov
approved these changes
Sep 10, 2023
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.
LGTM!
xunilrj
added
the
breaking
May cause existing user code to break. Requires a minor or major release.
label
Sep 10, 2023
anton-trunov
added
the
language feature
Core language features visible to end users
label
Sep 10, 2023
IGI-111
approved these changes
Sep 11, 2023
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.
This was referenced Sep 12, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking
May cause existing user code to break. Requires a minor or major release.
language feature
Core language features visible to end users
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.
Description
This PR introduces
string slices
.The basic usage is at
test/src/ir_generation/tests/str_slice.sw
:Before this PR
a
would be of typestr[3]
, a string array.Now both
string slices
andstring arrays
exist. This PR contains a new intrinsic that converts from string literals to arrays.Runtime conversions can be done using
string slices to string arrays can fail, so they return
Option<str[N]>
; and because of thistry_as_str_array
lives instd
. The inverse,from_str_array
only fails ifalloc
fails and lives incore
.At this PR
string slices
are forbidden atconfigurable
,storage
,const
, and main arguments and returns. The reason for these limitations is the internal structure ofstring slices
having aptr
.The optimized IR for initializing the slice is:
Checklist
Breaking*
orNew Feature
labels where relevant.