Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty string is treated as a void type at compile-time for var args functions #918

Closed
tiehuis opened this issue Apr 13, 2018 · 2 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@tiehuis
Copy link
Member

tiehuis commented Apr 13, 2018

const std = @import("std");

pub fn main() void {
    comptime const native_str = "";
    std.debug.warn(" {}\n", native_str);
}

Results in the following:

/home/me/local/lib/zig/std/debug/index.zig:22:23: error: compiler bug: var args can't handle void. https://github.com/zig-lang/zig/issues/557
    stderr.print(fmt, args) catch return;
                      ^
/tmp/t.zig:5:19: note: called from here
    std.debug.warn(" {}\n", native_str);

But using a non-empy string we get the expected value:

const std = @import("std");

pub fn main() void {
    comptime const native_str = "a";
    std.debug.warn(" {}\n", native_str);
}
@tiehuis tiehuis changed the title var args handle void empty string is treated as a void type at compile-time for var-args Apr 13, 2018
@tiehuis tiehuis added the bug Observed behavior contradicts documented or intended behavior label Apr 13, 2018
@tiehuis tiehuis changed the title empty string is treated as a void type at compile-time for var-args empty string is treated as a void type at compile-time for var args functions Apr 13, 2018
@andrewrk
Copy link
Member

I think this is the same problem as #557

@andrewrk andrewrk added this to the 0.3.0 milestone Apr 13, 2018
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Aug 24, 2018
@andrewrk andrewrk modified the milestones: 0.4.0, 0.5.0 Feb 15, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Aug 21, 2019
@andrewrk
Copy link
Member

andrewrk commented Dec 9, 2019

solved by removing var args from the language in a3f6a58

@andrewrk andrewrk closed this as completed Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants