generic args available to member functions

See #22
master
Andrew Kelley 2016-05-07 17:27:57 -07:00
parent 2ed72022ce
commit 9e0165147e
2 changed files with 4 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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 }
}