From 9e0165147e18ffb36bcaf09112c72f4cb397d563 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 7 May 2016 17:27:57 -0700 Subject: generic args available to member functions See #22 --- src/analyze.cpp | 2 +- test/self_hosted.zig | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/analyze.cpp b/src/analyze.cpp index c6160ce574..65075b9ab0 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1549,7 +1549,7 @@ static void preview_fn_proto(CodeGen *g, ImportTableEntry *import, AstNode *prot if (proto_node->data.fn_proto.generic_params.length > 0) { return preview_generic_fn_proto(g, import, proto_node); } else { - return preview_fn_proto_instance(g, import, proto_node, import->block_context); + return preview_fn_proto_instance(g, import, proto_node, proto_node->block_context); } } diff --git a/test/self_hosted.zig b/test/self_hosted.zig index 36c0cc9d6f..d8e4563bf2 100644 --- a/test/self_hosted.zig +++ b/test/self_hosted.zig @@ -1572,9 +1572,11 @@ fn generic_struct() { var a1 = GenNode(i32) {.value = 13, .next = null,}; var b1 = GenNode(bool) {.value = true, .next = null,}; assert(a1.value == 13); - assert(b1.value); + assert(a1.value == a1.get_val()); + assert(b1.get_val()); } struct GenNode(T: type) { value: T, next: ?&GenNode(T), + fn get_val(n: &const GenNode(T)) -> T { n.value } } -- cgit v1.2.3