-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.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.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
/home/andy/Downloads/zig/src/Sema.zig:28870:28: error: incompatible types: '[:0]const u8' and '[]u8'
const field_name = if (anon_struct.names.len != 0)
^~
/home/andy/Downloads/zig/src/Sema.zig:28871:42: note: type '[:0]const u8' here
mod.intern_pool.stringToSlice(anon_struct.names[field_i])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/andy/Downloads/zig/src/Sema.zig:28873:13: note: type '[]u8' here
try std.fmt.allocPrint(sema.arena, "{d}", .{field_i});
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reduction:
const std = @import("std");
const assert = std.debug.assert;
const expect = std.testing.expect;
test "peer type resolution with const sentinel slice and mutable slice" {
var buf: [4]u8 = "blah".*;
var a: [:0]const u8 = "hello";
var b: []u8 = &buf;
var t = true;
const result1 = if (t) a else b;
const result2 = if (!t) a else b;
comptime assert(@TypeOf(result1) == []const u8);
comptime assert(@TypeOf(result2) == []const u8);
try expect(std.mem.eql(u8, a, "hello"));
try expect(std.mem.eql(u8, b, "blah"));
}test3.zig:10:21: error: incompatible types: '[:0]const u8' and '[]u8'
const result1 = if (t) a else b;
^~~~~~~~~~~~~~~
test3.zig:10:28: note: type '[:0]const u8' here
const result1 = if (t) a else b;
^
test3.zig:10:35: note: type '[]u8' here
const result1 = if (t) a else b;
^
Metadata
Metadata
Assignees
Labels
contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.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.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.