| ... | @@ -27,6 +27,7 @@ static TypeTableEntry *analyze_error_literal_expr(CodeGen *g, ImportTableEntry * | ... | @@ -27,6 +27,7 @@ static TypeTableEntry *analyze_error_literal_expr(CodeGen *g, ImportTableEntry * |
| 27 | static TypeTableEntry *analyze_block_expr(CodeGen *g, ImportTableEntry *import, BlockContext *context, | 27 | static TypeTableEntry *analyze_block_expr(CodeGen *g, ImportTableEntry *import, BlockContext *context, |
| 28 | TypeTableEntry *expected_type, AstNode *node); | 28 | TypeTableEntry *expected_type, AstNode *node); |
| 29 | static TypeTableEntry *resolve_expr_const_val_as_void(CodeGen *g, AstNode *node); | 29 | static TypeTableEntry *resolve_expr_const_val_as_void(CodeGen *g, AstNode *node); |
| | 30 | static TypeTableEntry *resolve_expr_const_val_as_fn(CodeGen *g, AstNode *node, FnTableEntry *fn); |
| 30 | static void detect_top_level_decl_deps(CodeGen *g, ImportTableEntry *import, AstNode *node); | 31 | static void detect_top_level_decl_deps(CodeGen *g, ImportTableEntry *import, AstNode *node); |
| 31 | | 32 | |
| 32 | static AstNode *first_executing_node(AstNode *node) { | 33 | static AstNode *first_executing_node(AstNode *node) { |
| ... | @@ -1895,13 +1896,23 @@ static TypeTableEntry *analyze_field_access_expr(CodeGen *g, ImportTableEntry *i | ... | @@ -1895,13 +1896,23 @@ static TypeTableEntry *analyze_field_access_expr(CodeGen *g, ImportTableEntry *i |
| 1895 | return g->builtin_types.entry_invalid; | 1896 | return g->builtin_types.entry_invalid; |
| 1896 | } | 1897 | } |
| 1897 | } else if (struct_type->id == TypeTableEntryIdMetaType) { | 1898 | } else if (struct_type->id == TypeTableEntryIdMetaType) { |
| 1898 | TypeTableEntry *enum_type = resolve_type(g, struct_expr_node); | 1899 | TypeTableEntry *child_type = resolve_type(g, struct_expr_node); |
| 1899 | | 1900 | |
| 1900 | if (enum_type->id == TypeTableEntryIdInvalid) { | 1901 | if (child_type->id == TypeTableEntryIdInvalid) { |
| 1901 | return g->builtin_types.entry_invalid; | 1902 | return g->builtin_types.entry_invalid; |
| 1902 | } else if (enum_type->id == TypeTableEntryIdEnum) { | 1903 | } else if (child_type->id == TypeTableEntryIdEnum) { |
| 1903 | return analyze_enum_value_expr(g, import, context, node, nullptr, enum_type, field_name); | 1904 | return analyze_enum_value_expr(g, import, context, node, nullptr, child_type, field_name); |
| 1904 | } else if (enum_type->id == TypeTableEntryIdPureError) { | 1905 | } else if (child_type->id == TypeTableEntryIdStruct) { |
| | 1906 | auto entry = child_type->data.structure.fn_table.maybe_get(field_name); |
| | 1907 | if (entry) { |
| | 1908 | return resolve_expr_const_val_as_fn(g, node, entry->value); |
| | 1909 | } else { |
| | 1910 | add_node_error(g, node, |
| | 1911 | buf_sprintf("struct '%s' has no function called '%s'", |
| | 1912 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| | 1913 | return g->builtin_types.entry_invalid; |
| | 1914 | } |
| | 1915 | } else if (child_type->id == TypeTableEntryIdPureError) { |
| 1905 | return analyze_error_literal_expr(g, import, context, node, field_name); | 1916 | return analyze_error_literal_expr(g, import, context, node, field_name); |
| 1906 | } else { | 1917 | } else { |
| 1907 | add_node_error(g, node, | 1918 | add_node_error(g, node, |