Skip to content

Instantly share code, notes, and snippets.

@fengb

fengb/tuple.zig Secret

Created January 28, 2020 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fengb/e6af2dc55fbc7cc783bef562162ac106 to your computer and use it in GitHub Desktop.
Save fengb/e6af2dc55fbc7cc783bef562162ac106 to your computer and use it in GitHub Desktop.
fn Pair(comptime T0: type, comptime T1: type) type {
return @TypeOf(.{ @as(T0, undefined), @as(T1, undefined) });
}
fn add(p: Pair(i32, i32)) i32 {
return p[0] + p[1];
}
test "" {
_ = add;
}
@fengb
Copy link
Author

fengb commented Jan 28, 2020

./tuple:6:13: error: use of undefined value here causes undefined behavior
    return p[0] + p[1];
            ^
./tuple:6:17: note: referenced here
    return p[0] + p[1];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment