-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Milestone
Description
Zig Version
0.11.0-dev.1557+03cdb4fb5
Steps to Reproduce and Observed Behavior
const std = @import("std");
pub fn main() void {
const foo = factory();
const bar = factory();
std.debug.print("{s}\n", .{@typeName(@TypeOf(foo))});
std.debug.print("{s}\n", .{foo([]const u8, "Hello")});
std.debug.print("{s}\n", .{@typeName(@TypeOf(bar))});
std.debug.print("{s}\n", .{bar([]const u8, "Hello")});
}
fn factory() (fn (type, anytype) i32) {
return struct {
fn id(comptime T: type, bar: T) T {
return bar;
}
}.id;
}output:
fn(comptime type, anytype) anytype
Hello
fn(comptime type, anytype) i32
HelloExpected Behavior
Two functions foo and bar should have a same type.
Also the compiler thinks that bar returns i32 at that point, but it successfully returns of type []const u8.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior