-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Description
Zig Version
0.14.0-dev.2922+f77e1b862
Steps to Reproduce and Observed Behavior
0.13.0 Godbolt Working
0.14.0 Godbolt Erroring
- Set up a Zig project and compile the following minimal repro using the specified version:
const std = @import("std");
const L = struct { a: u1 };
const S = struct {
items: []const L = &.{},
pub fn a(comptime self: *S) *S {
self.items = self.items ++ .{.{ .a = 0 }};
return self;
}
};
pub fn main() !void {
comptime {
var s = S{};
_ = s.a();
}
}
- Notice the error:
run
└─ run ZigUnexpectedTypeCoercionError
└─ zig build-exe ZigUnexpectedTypeCoercionError Debug native 1 errors
src/main.zig:9:39: error: expected type 'main.L', found 'main.S.a__struct_2486'
self.items = self.items ++ .{.{ .a = 0 }};
~^~~~~~~~~~
src/main.zig:9:39: note: struct declared here
src/main.zig:3:11: note: struct declared here
const L = struct { a: u1 };
^~~~~~~~~~~~~~~~
src/main.zig:17:16: note: called from here
_ = s.a();
~~~^~
Expected Behavior
As it was a feature that worked in 0.13.0 I'd expect this to work the same way in 0.14.0
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior