authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-08-16 23:24:33-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-08-16 23:24:33-07:00
log0fbb9e09ea89ea24ec214b244e1de9574516c74c
tree49f3de24d33fe361500e0400215aea73326d7700
parenta2ac06dcd506fd5e119e4eb8e1de201fefa05bbc

fix crash when calling method on slice


2 files changed, 7 insertions(+), 1 deletions(-)

src/analyze.cpp+1-1
......@@ -2686,7 +2686,7 @@ static TypeTableEntry *analyze_field_access_expr(CodeGen *g, ImportTableEntry *i
26862686 node->data.field_access_expr.type_struct_field = find_struct_type_field(bare_struct_type, field_name);
26872687 if (node->data.field_access_expr.type_struct_field) {
26882688 return node->data.field_access_expr.type_struct_field->type_entry;
2689 } else if (wrapped_in_fn_call) {
2689 } else if (wrapped_in_fn_call && !is_slice(bare_struct_type)) {
26902690 BlockContext *container_block_context = get_container_block_context(bare_struct_type);
26912691 assert(container_block_context);
26922692 auto entry = container_block_context->decl_table.maybe_get(field_name);
test/run_tests.cpp+6
......@@ -1451,6 +1451,12 @@ fn function_with_return_type_type() {
14511451 ".tmp_source.zig:3:5: error: failed to evaluate function at compile time",
14521452 ".tmp_source.zig:4:5: note: unable to evaluate this expression at compile time",
14531453 ".tmp_source.zig:3:32: note: required to be compile-time function because of return type 'type'");
1454
1455 add_compile_fail_case("bogus method call on slice", R"SOURCE(
1456fn f(m: []const u8) {
1457 m.copy(u8, self.list.items[old_len...], m);
1458}
1459 )SOURCE", 1, ".tmp_source.zig:3:6: error: no member named 'copy' in '[]const u8'");
14541460}
14551461
14561462//////////////////////////////////////////////////////////////////////////////