Skip to content

If you set a function public, all the input and output parameter type must be public, or you will get a compile error #1183

@bronze1man

Description

@bronze1man

I have saw the part of the source code in the std/io.zig

pub fn getStdOut() GetStdIoErrs!File {
    const handle = if (is_windows) try os.windowsGetStdHandle(os.windows.STD_OUTPUT_HANDLE) else if (is_posix) os.posix.STDOUT_FILENO else unreachable;
    return File.openHandle(handle);
}

I think the return type is like !std.io.File so I write follow code:

fn getStdOut() !std.io.File{
 return std.io.getStdOut();
}

But it is not work:

xxx/h.zig:11:23: error: 'File' is private
fn getStdOut() !std.io.File{
                      ^
/usr/local/zig/build/lib/zig/std/io.zig:13:1: note: declared here
const File = std.os.File;

So I have to change the code like this(it works):

fn getStdOut() !std.os.File{
 return std.io.getStdOut();
}

So I have follow proposal:

  • If you set a function public, all the input and output parameter type must be public, or you will get a compile error.

This proposal will make reading code easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions