Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Created January 23, 2017 07:49
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 andrewrk/fd54e7453f8f6e8becaeb13cba7b9a7d to your computer and use it in GitHub Desktop.
Save andrewrk/fd54e7453f8f6e8becaeb13cba7b9a7d to your computer and use it in GitHub Desktop.
compile errors for generic function instantiation in zig
./test.zig:2:7: error: incompatible types: 'i32' and 'f64'
a + b
^
./test.zig:6:8: note: called from here
add(a, b)
^
./test.zig:10:8: note: called from here
foo(a, b)
^
./test.zig:14:8: note: called from here
bar(f64, 123, 456)
^
./test.zig:2:5: note: type 'i32' here
a + b
^
./test.zig:2:9: note: type 'f64' here
a + b
^
fn add(a: var, b: var) -> @typeOf(a) {
a + b
}
fn foo(a: var, b: var) -> i32 {
add(a, b)
}
fn bar(comptime T: type, a: i32, b: T) -> i32 {
foo(a, b)
}
fn baz() -> i32 {
bar(f64, 123, 456)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment