| ... | ... | @@ -29,6 +29,8 @@ static TypeTableEntry *analyze_block_expr(CodeGen *g, ImportTableEntry *import, |
| 29 | 29 | static TypeTableEntry *resolve_expr_const_val_as_void(CodeGen *g, AstNode *node); |
| 30 | 30 | static TypeTableEntry *resolve_expr_const_val_as_fn(CodeGen *g, AstNode *node, FnTableEntry *fn); |
| 31 | 31 | static TypeTableEntry *resolve_expr_const_val_as_type(CodeGen *g, AstNode *node, TypeTableEntry *type); |
| 32 | static TypeTableEntry *resolve_expr_const_val_as_unsigned_num_lit(CodeGen *g, AstNode *node, |
| 33 | TypeTableEntry *expected_type, uint64_t x); |
| 32 | 34 | static void detect_top_level_decl_deps(CodeGen *g, ImportTableEntry *import, AstNode *node); |
| 33 | 35 | static void analyze_top_level_decls_root(CodeGen *g, ImportTableEntry *import, AstNode *node); |
| 34 | 36 | |
| ... | ... | @@ -2229,7 +2231,7 @@ static TypeTableEntry *analyze_container_init_expr(CodeGen *g, ImportTableEntry |
| 2229 | 2231 | } |
| 2230 | 2232 | |
| 2231 | 2233 | static TypeTableEntry *analyze_field_access_expr(CodeGen *g, ImportTableEntry *import, BlockContext *context, |
| 2232 | | AstNode *node) |
| 2234 | TypeTableEntry *expected_type, AstNode *node) |
| 2233 | 2235 | { |
| 2234 | 2236 | assert(node->type == NodeTypeFieldAccessExpr); |
| 2235 | 2237 | |
| ... | ... | @@ -2266,7 +2268,8 @@ static TypeTableEntry *analyze_field_access_expr(CodeGen *g, ImportTableEntry *i |
| 2266 | 2268 | } |
| 2267 | 2269 | } else if (struct_type->id == TypeTableEntryIdArray) { |
| 2268 | 2270 | if (buf_eql_str(field_name, "len")) { |
| 2269 | | return g->builtin_types.entry_isize; |
| 2271 | return resolve_expr_const_val_as_unsigned_num_lit(g, node, expected_type, |
| 2272 | struct_type->data.array.len); |
| 2270 | 2273 | } else { |
| 2271 | 2274 | add_node_error(g, node, |
| 2272 | 2275 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), |
| ... | ... | @@ -2671,7 +2674,7 @@ static TypeTableEntry *analyze_lvalue(CodeGen *g, ImportTableEntry *import, Bloc |
| 2671 | 2674 | } else if (lhs_node->type == NodeTypeArrayAccessExpr) { |
| 2672 | 2675 | expected_rhs_type = analyze_array_access_expr(g, import, block_context, lhs_node); |
| 2673 | 2676 | } else if (lhs_node->type == NodeTypeFieldAccessExpr) { |
| 2674 | | expected_rhs_type = analyze_field_access_expr(g, import, block_context, lhs_node); |
| 2677 | expected_rhs_type = analyze_field_access_expr(g, import, block_context, nullptr, lhs_node); |
| 2675 | 2678 | } else if (lhs_node->type == NodeTypePrefixOpExpr && |
| 2676 | 2679 | lhs_node->data.prefix_op_expr.prefix_op == PrefixOpDereference) |
| 2677 | 2680 | { |
| ... | ... | @@ -4849,7 +4852,7 @@ static TypeTableEntry *analyze_expression(CodeGen *g, ImportTableEntry *import, |
| 4849 | 4852 | return_type = analyze_slice_expr(g, import, context, node); |
| 4850 | 4853 | break; |
| 4851 | 4854 | case NodeTypeFieldAccessExpr: |
| 4852 | | return_type = analyze_field_access_expr(g, import, context, node); |
| 4855 | return_type = analyze_field_access_expr(g, import, context, expected_type, node); |
| 4853 | 4856 | break; |
| 4854 | 4857 | case NodeTypeContainerInitExpr: |
| 4855 | 4858 | return_type = analyze_container_init_expr(g, import, context, node); |