-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[stdlib] Fix make String.join()
work on StringSlice
#3677
base: nightly
Are you sure you want to change the base?
Conversation
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Is this still something you want to keep in Draft or push forward with while other things are stalled on compiler issues? |
This depends on #3528, I reimplemented the code for |
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
@JoeLoser I reimplemented the fn test_string_byte_span() raises:
var string = String("Hello")
var str_slice = string.as_bytes() # removed this
var str_slice = string.as_bytes[is_mutable=True]() # added this
...
var sub1 = str_slice[:5]
...
var sub2 = str_slice[2:5]
...
#
# Test mutation through slice
#
sub1[0] = ord("J")
assert_equal(string, "Jello")
sub2[2] = ord("y")
assert_equal(string, "Jelly") If that is what you mean then it's a matter of just changing all calls that do that |
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
!sync |
This is still crashing internally in the parser, e.g.
which is an internal assertion in the parser. The parser can't even parse
Can you rebase this PR and see if it also repros in the OSS repo with latest |
This branch is up to date with latest nightly and I'm using
This makes me think that there is some transformation missing on the way, AFAIK the Mojo compiler progressively lowers stuff, so I'm thinking it keeps it The trail might start at the generic function (the more generic the later mojo lowers stuff AFAIK) which expects a fn _join_bytes[
T: AsBytesCollectionElement, //,
](self, elems: List[T, *_]) -> String:
...
for e in elems:
len_elems += len(e[].as_bytes[False, __origin_of(e)]()) An easy way to find out is to comment it and paste the current nightly join implementation: var result: String = ""
var is_first = True
for e in elems:
if is_first:
is_first = False
else:
result += self
result += str(e[])
return result One idea I'm having is that for these kind of generic functions it might be better to use Beyond that I have no idea if it's solvable on the user side, and I can't repro it so I can't help :( |
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
@JoeLoser I think I fixed the issue (I believe it was just the origin casting), if you want to test it out whenever you have time. I have no problem waiting since I decoupled this feature from the other PRs where it was needed (just used |
Fix make
String.join()
work onStringSlice
by using thefast_join()
method now renamed_join_bytes()
without needing to allocate for each slice. Changes toAsBytes
were needed to allow for non-owning types to work with it (StringSlice
).