zig icon indicating copy to clipboard operation
zig copied to clipboard

expected type 'type', found 'fn(comptime type) type' complains about wrong line

Open codethief opened this issue 2 years ago • 0 comments

Zig Version

0.11.0-dev.1836+28364166e

Steps to Reproduce and Observed Output

Hi there, I have a function

pub fn foo(param1: anytype, param2: bool) bool {
    var buffer: [200]u8 = undefined;
    const stream: std.io.FixedBufferStream = std.io.fixedBufferStream(&buffer);
    const writer = stream.writer();
    // ...
    return true;
}

and am getting the following error:

src/string_ops.zig:94:1: error: expected type 'type', found 'fn(comptime type) type'
pub fn foo(param1: anytype, param2: bool) bool {
^~~

I realize this is due std.io.FixedBufferStream, which is not a type but a function. However, the error message complains about foo().

Expected Output

src/string_ops.zig:xx:x: error: expected type 'type', found 'fn(comptime type) type'
    const stream: std.io.FixedBufferStream = std.io.fixedBufferStream(&buffer);
                  ^~~

codethief avatar Mar 03 '23 00:03 codethief