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

Concatenating tuples with a mix of runtime and comptime values fails #4571

Closed
alexnask opened this issue Feb 27, 2020 · 2 comments · Fixed by #4573
Closed

Concatenating tuples with a mix of runtime and comptime values fails #4571

alexnask opened this issue Feb 27, 2020 · 2 comments · Fixed by #4573
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@alexnask
Copy link
Contributor

alexnask commented Feb 27, 2020

const std = @import("std");
const assert = std.debug.assert;

fn consume_tuple(tuple: var) void {}

test "tuple concatenation" {
    const t1 = .{};

    var rt_var: u8 = 0;
    const t2 = .{rt_var}; // Same with var t2 = .{rt_var};

    // The following work.
    consume_tuple(t1 ++ t1);
    consume_tuple(.{} ++ .{});
    consume_tuple(.{0} ++ .{});
    consume_tuple(.{0} ++ .{1});
    consume_tuple(.{0, 1, 2} ++ .{u8, 1, noreturn});
    consume_tuple(t2 ++ t1);
    consume_tuple(t1 ++ t2);
    consume_tuple(t2 ++ t2);

    // The following error with message: "unable to evaluate constant expression"
    consume_tuple(.{rt_var} ++ t1);
    consume_tuple(.{} ++ .{rt_var});
    consume_tuple(.{u8} ++ .{rt_var});

    // The following error with message: "cannot assign to constant"
    consume_tuple(t2 ++ .{void});
    consume_tuple(t2 ++ .{0});
    consume_tuple(.{0} ++ t2);
    consume_tuple(.{void} ++ t2);
}
@mlarouche
Copy link
Sponsor Contributor

I have to do this workaround in a project to give a nice abstraction to call COM interface https://gist.github.com/mlarouche/c558881a9e51c45ef05577363de1602f#file-com_call-zig-L43

@alexnask
Copy link
Contributor Author

Also relevant
Workaround in my std.interface PR:

// TODO: This errors with "cannot assign to constant"

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Feb 29, 2020
@andrewrk andrewrk added this to the 0.6.0 milestone Feb 29, 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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants