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

compiler assert when referencing varargs in return type expression #2376

Closed
tgschultz opened this issue Apr 29, 2019 · 2 comments
Closed

compiler assert when referencing varargs in return type expression #2376

tgschultz opened this issue Apr 29, 2019 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@tgschultz
Copy link
Contributor

const std = @import("std");

pub fn foo(args: ...) @typeOf(args[0]) {
    return args[0];
}

test "" {
    const x = foo(i32(1), i64(2));
}

This should ultimately be fixed by #208.

@andrewrk andrewrk added this to the 0.5.0 milestone Apr 29, 2019
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Apr 29, 2019
@SamTebbs33
Copy link
Contributor

It looks like args should be comptime since @typeOf is used on them. Should this be a compile error?

@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Sep 27, 2019
@andrewrk
Copy link
Member

andrewrk commented Jan 5, 2020

What's this I found, a var args bug report? Solved by deleting var args from the language!

const std = @import("std");

pub fn foo(args: var) @TypeOf(args[0]) {
    return args[0];
}

test "" {
    const x = foo(.{ @as(i32, 1), @as(i64, 2) });
}
[nix-shell:~/dev/zig/build]$ ./zig test test.zig 
All 1 tests passed.

@andrewrk andrewrk closed this as completed Jan 5, 2020
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

3 participants