Skip to content
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

Overly agressive constness check on comptime copied slices #8644

Open
N00byEdge opened this issue Apr 29, 2021 · 1 comment
Open

Overly agressive constness check on comptime copied slices #8644

N00byEdge opened this issue Apr 29, 2021 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@N00byEdge
Copy link
Sponsor Contributor

  comptime var x: []u8 = &[_]u8{};
  x = x ++ "a";

Fails with the following error:

./example.zig:3:9: error: expected type '[]u8', found '*const [1:0]u8'
  x = x ++ "a";
        ^

Godbolt: https://gcc.godbolt.org/z/he94PY3bx
Should probably be allowed since this is a value copy, not a reference

@SpexGuy SpexGuy added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Apr 29, 2021
@N00byEdge
Copy link
Sponsor Contributor Author

Workaround:

  comptime var x: []const u8 = &[_]u8{};
  x = x ++ "a";

@andrewrk andrewrk added this to the 0.10.0 milestone May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

3 participants