Skip to content

Can't cast variable length data to slice ([]u8 in this case). #2126

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

Closed
shawnl opened this issue Mar 28, 2019 · 3 comments
Closed

Can't cast variable length data to slice ([]u8 in this case). #2126

shawnl opened this issue Mar 28, 2019 · 3 comments
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@shawnl
Copy link
Contributor

shawnl commented Mar 28, 2019

I should be able to do this:

var char: u21 = undefined;
var hex_escape_bytes: u2 = undefined;
...
                std.fmt.hexToBytes(@ptrCast(*[hex_escape_bytes]u8, &char).*[0..],
                    char_token[2...2 + hex_escape_bytes]) catch unreachable;

Its not a VLA because it is being cast to a slice.

I don't need to use hexToBytes, I can just use charToDigit directly (i also don't want to create the slice manually), but I wanted to note this.

@shawnl
Copy link
Contributor Author

shawnl commented Mar 28, 2019

related to #863

@shawnl
Copy link
Contributor Author

shawnl commented Mar 28, 2019

It would be nice if this could be done in a way that preserved the bounds checking.

@andrewrk andrewrk added this to the 0.5.0 milestone Mar 29, 2019
@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Mar 29, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Apr 30, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Dec 31, 2019
@andrewrk
Copy link
Member

not a valid example because hex_escape_bytes is a runtime value.

@andrewrk andrewrk modified the milestones: 0.7.0, 0.6.0 Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

2 participants