| ... | @@ -1378,6 +1378,15 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A | ... | @@ -1378,6 +1378,15 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A |
| 1378 | child_import->error_table.init(8); | 1378 | child_import->error_table.init(8); |
| 1379 | child_import->c_import_node = node; | 1379 | child_import->c_import_node = node; |
| 1380 | | 1380 | |
| | 1381 | child_import->importers.append({parent_import, node}); |
| | 1382 | |
| | 1383 | if (node->data.c_import.visib_mod != VisibModPrivate) { |
| | 1384 | for (int i = 0; i < parent_import->importers.length; i += 1) { |
| | 1385 | ImporterInfo importer = parent_import->importers.at(i); |
| | 1386 | child_import->importers.append(importer); |
| | 1387 | } |
| | 1388 | } |
| | 1389 | |
| 1381 | ZigList<ErrorMsg *> errors = {0}; | 1390 | ZigList<ErrorMsg *> errors = {0}; |
| 1382 | | 1391 | |
| 1383 | int err; | 1392 | int err; |
| ... | @@ -1391,6 +1400,10 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A | ... | @@ -1391,6 +1400,10 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A |
| 1391 | ErrorMsg *err_msg = errors.at(i); | 1400 | ErrorMsg *err_msg = errors.at(i); |
| 1392 | err_msg_add_note(parent_err_msg, err_msg); | 1401 | err_msg_add_note(parent_err_msg, err_msg); |
| 1393 | } | 1402 | } |
| | 1403 | |
| | 1404 | for (int i = 0; i < child_import->importers.length; i += 1) { |
| | 1405 | child_import->importers.at(i).import->any_imports_failed = true; |
| | 1406 | } |
| 1394 | return; | 1407 | return; |
| 1395 | } | 1408 | } |
| 1396 | | 1409 | |
| ... | @@ -1402,14 +1415,6 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A | ... | @@ -1402,14 +1415,6 @@ static void resolve_c_import_decl(CodeGen *g, ImportTableEntry *parent_import, A |
| 1402 | | 1415 | |
| 1403 | child_import->di_file = parent_import->di_file; | 1416 | child_import->di_file = parent_import->di_file; |
| 1404 | child_import->block_context = new_block_context(child_import->root, nullptr); | 1417 | child_import->block_context = new_block_context(child_import->root, nullptr); |
| 1405 | child_import->importers.append({parent_import, node}); | | |
| 1406 | | | |
| 1407 | if (node->data.c_import.visib_mod != VisibModPrivate) { | | |
| 1408 | for (int i = 0; i < parent_import->importers.length; i += 1) { | | |
| 1409 | ImporterInfo importer = parent_import->importers.at(i); | | |
| 1410 | child_import->importers.append(importer); | | |
| 1411 | } | | |
| 1412 | } | | |
| 1413 | | 1418 | |
| 1414 | detect_top_level_decl_deps(g, child_import, child_import->root); | 1419 | detect_top_level_decl_deps(g, child_import, child_import->root); |
| 1415 | analyze_top_level_decls_root(g, child_import, child_import->root); | 1420 | analyze_top_level_decls_root(g, child_import, child_import->root); |
| ... | @@ -2613,6 +2618,12 @@ static TypeTableEntry *analyze_symbol_expr(CodeGen *g, ImportTableEntry *import, | ... | @@ -2613,6 +2618,12 @@ static TypeTableEntry *analyze_symbol_expr(CodeGen *g, ImportTableEntry *import, |
| 2613 | return resolve_expr_const_val_as_fn(g, node, context, fn_table_entry->value); | 2618 | return resolve_expr_const_val_as_fn(g, node, context, fn_table_entry->value); |
| 2614 | } | 2619 | } |
| 2615 | | 2620 | |
| | 2621 | if (import->any_imports_failed) { |
| | 2622 | // skip the error message since we had a failing import in this file |
| | 2623 | // if an import breaks we don't need 9999 undeclared identifier errors |
| | 2624 | return g->builtin_types.entry_invalid; |
| | 2625 | } |
| | 2626 | |
| 2616 | add_node_error(g, node, buf_sprintf("use of undeclared identifier '%s'", buf_ptr(variable_name))); | 2627 | add_node_error(g, node, buf_sprintf("use of undeclared identifier '%s'", buf_ptr(variable_name))); |
| 2617 | return g->builtin_types.entry_invalid; | 2628 | return g->builtin_types.entry_invalid; |
| 2618 | } | 2629 | } |