You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
andrewrk opened this issue
Nov 25, 2019
· 1 comment
Labels
acceptedThis proposal is planned.breakingImplementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.
Now that #265 is done, the main motivation for type coercion from array values to slices is gone. It's a footgun for Zig to automatically convert a value into a pointer to that value; such an operation should be explicit.
test"coerce array value to slice" {
vararray: []consti32= [_]i32{ 1, 2, 3, 4 };
}
Expected output:
test.zig:2:30: error: expected type '[]const i32', found '[4]i32'
var array: []const i32 = [_]i32{ 1, 2, 3, 4 };
^
I expect this change to simplify the result location semantics, which should help with reasoning about zig code, as well as reduce the complexity of a zig compiler.
The text was updated successfully, but these errors were encountered:
andrewrk
added
breaking
Implementing this issue could cause existing code to no longer compile or have different behavior.
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
accepted
This proposal is planned.
labels
Nov 25, 2019
andrewrk
changed the title
Remove type coercion from array values which do not have static lifetimes to references
remove type coercion from array values to references
Nov 25, 2019
* Implements #3768. This is a sweeping breaking change that requires
many (trivial) edits to Zig source code. Array values no longer
coerced to slices; however one may use `&` to obtain a reference to
an array value, which may then be coerced to a slice.
* Adds `IrInstruction::dump`, for debugging purposes. It's useful to
call to inspect the instruction when debugging Zig IR.
* Fixes bugs with result location semantics. See the new behavior test
cases, and compile error test cases.
* Fixes bugs with `@typeInfo` not properly resolving const values.
* Behavior tests are passing but std lib tests are not yet. There
is more work to do before merging this branch.
acceptedThis proposal is planned.breakingImplementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.
Now that #265 is done, the main motivation for type coercion from array values to slices is gone. It's a footgun for Zig to automatically convert a value into a pointer to that value; such an operation should be explicit.
Expected output:
Actual output: (test passes)
How to upgrade code for these new semantics:
I expect this change to simplify the result location semantics, which should help with reasoning about zig code, as well as reduce the complexity of a zig compiler.
The text was updated successfully, but these errors were encountered: