Fixed crash when resolving peer types of *[N:s]const T and [*:s]const T

master
Alexandros Naskos 2020-06-24 21:04:31 +03:00 committed by Andrew Kelley
parent d337469e44
commit 2fde8249b7
3 changed files with 8 additions and 0 deletions

View File

@ -12603,6 +12603,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
prev_type->data.pointer.child_type->id == ZigTypeIdArray &&
((cur_type->id == ZigTypeIdPointer && cur_type->data.pointer.ptr_len == PtrLenUnknown)))
{
convert_to_const_slice = false;
prev_inst = cur_inst;
if (prev_type->data.pointer.is_const && !cur_type->data.pointer.is_const) {

View File

@ -50,6 +50,7 @@ comptime {
_ = @import("behavior/bugs/4769_b.zig");
_ = @import("behavior/bugs/4769_c.zig");
_ = @import("behavior/bugs/4954.zig");
_ = @import("behavior/bugs/5413.zig");
_ = @import("behavior/bugs/5474.zig");
_ = @import("behavior/bugs/5487.zig");
_ = @import("behavior/bugs/394.zig");

View File

@ -0,0 +1,6 @@
const expect = @import("std").testing.expect;
test "Peer type resolution with string literals and unknown length u8 pointers" {
expect(@TypeOf("", "a", @as([*:0]const u8, "")) == [*:0]const u8);
expect(@TypeOf(@as([*:0]const u8, "baz"), "foo", "bar") == [*:0]const u8);
}