-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.stage1The process of building from source via WebAssembly and the C backend.The process of building from source via WebAssembly and the C backend.
Milestone
Description
Extracted from #4752.
Test case:
const std = @import("std");
fn foo(c: u8, char_buf: *[4]u8) []const u8 {
return switch (c) {
'\"' => "\\\"",
'\'' => "\\'",
'\\' => "\\\\",
'\n' => "\\n",
'\r' => "\\r",
'\t' => "\\t",
else => {
if (c == 10) {
return bar(char_buf);
} else {
return bar(char_buf);
}
},
};
}
fn bar(buf: []u8) []u8 {
buf[0..4].* = "abcd".*;
return buf;
}
test "peer type resolution for slice and single-pointer-to-array" {
var buf: [4]u8 = undefined;
std.testing.expect(std.mem.eql(u8, foo('\\', &buf), "\\"));
std.testing.expect(std.mem.eql(u8, foo(10, &buf), "abcd"));
}Expected to pass. Instead:
./test2.zig:3:33: error: incompatible types: '[]u8' and '*const [2:0]u8'
fn foo(c: u8, char_buf: *[4]u8) []const u8 {
^
./test2.zig:13:27: note: type '[]u8' here
return bar(char_buf);
^
./test2.zig:5:17: note: type '*const [2:0]u8' here
'\"' => "\\\"",
^
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.stage1The process of building from source via WebAssembly and the C backend.The process of building from source via WebAssembly and the C backend.