Created
January 23, 2017 07:49
-
-
Save andrewrk/fd54e7453f8f6e8becaeb13cba7b9a7d to your computer and use it in GitHub Desktop.
compile errors for generic function instantiation in zig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./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 | |
^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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