Skip to content

Commit fc9205f

Browse files
committed
fix: process imports before extern declarations
Reorder type processing to: 1. Process imports first to register opaque types from stdlib 2. Then process extern declarations from merged program This ensures TypeRegistry has all type information before lowering. Note: Types are still resolved to TypeId(0) placeholders during parsing of main program. Full fix requires either: - Two-pass parsing (parse imports, then reparse main) - Lazy type resolution in lowering phase Current state: imports work and merge declarations, but type resolution from imports needs additional work in lowering phase.
1 parent 640e484 commit fc9205f

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

crates/zyntax_embed/src/runtime.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -811,13 +811,15 @@ impl ZyntaxRuntime {
811811
let module_name = InternedString::new_global("main");
812812
let mut type_registry = TypeRegistry::new();
813813

814-
// Process extern declarations to register opaque types (needs &mut)
815-
self.process_extern_declarations_mut(&program, &mut type_registry)?;
816-
817-
// Process imports to load stdlib traits and impls BEFORE lowering
818-
// This must happen before wrapping type_registry in Arc since it needs &mut
814+
// Process imports FIRST to load stdlib traits and impls
815+
// This merges declarations from imported modules into the program
816+
// and registers their opaque types in the type registry
819817
self.process_imports_for_traits(&mut program, &mut type_registry)?;
820818

819+
// Now process extern declarations from the merged program (main + imports)
820+
// to ensure all opaque types are registered (needs &mut)
821+
self.process_extern_declarations_mut(&program, &mut type_registry)?;
822+
821823
// Wrap in Arc for sharing
822824
let type_registry = std::sync::Arc::new(type_registry);
823825

0 commit comments

Comments
 (0)