pr 03.03
This commit is contained in:
@@ -141,6 +141,8 @@ pub fn compile_project(
|
||||
for (alias, project_id) in &step.deps {
|
||||
if let Some(compiled) = dep_modules.get(project_id) {
|
||||
for (key, _meta) in &compiled.exports {
|
||||
// Track both legacy and canonical forms ONLY for collision detection between deps and local modules.
|
||||
// Import resolution uses only '@alias:module' elsewhere.
|
||||
let synthetic_paths = [
|
||||
format!("{}/{}", alias, key.module_path),
|
||||
format!("@{}:{}", alias, key.module_path),
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::frontends::pbs::{parser::Parser, SymbolCollector, ModuleSymbols, Reso
|
||||
use crate::lowering::core_to_vm;
|
||||
use crate::common::spans::FileId;
|
||||
use frontend_api::traits::{Frontend as CanonFrontend, FrontendUnit};
|
||||
use frontend_api::types::{Diagnostic as CanonDiagnostic, Severity as CanonSeverity, ExportItem, ExportKind, ItemName, LoweredIr};
|
||||
use frontend_api::types::{Diagnostic as CanonDiagnostic, Severity as CanonSeverity, ExportItem, ExportKind, ItemName, LoweredIr, ImportRef, parse_pbs_from_string};
|
||||
use prometeu_analysis::NameInterner;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -59,8 +59,36 @@ impl CanonFrontend for PbsFrontendAdapter {
|
||||
return FrontendUnit { diagnostics: diags, imports: vec![], exports: vec![], lowered_ir: LoweredIr::default() };
|
||||
}
|
||||
|
||||
// TODO: Collect canonical imports from resolver.imported_symbols if/when available
|
||||
let imports = Vec::new();
|
||||
// Collect canonical imports from AST imports: `from` must be "@alias:module" and items single identifiers
|
||||
let mut imports: Vec<ImportRef> = Vec::new();
|
||||
if let crate::frontends::pbs::ast::NodeKind::File(file_node) = parsed.arena.kind(parsed.root) {
|
||||
for imp_id in &file_node.imports {
|
||||
if let crate::frontends::pbs::ast::NodeKind::Import(imp) = parsed.arena.kind(*imp_id) {
|
||||
// Parse project/module from `from` string
|
||||
match parse_pbs_from_string(&imp.from) {
|
||||
Ok((project, module)) => {
|
||||
// Resolve item names from spec node
|
||||
if let crate::frontends::pbs::ast::NodeKind::ImportSpec(spec) = parsed.arena.kind(imp.spec) {
|
||||
for &name_id in &spec.path {
|
||||
let name_str = interner.resolve(name_id);
|
||||
match ItemName::new(name_str) {
|
||||
Ok(item) => imports.push(ImportRef::new(project.clone(), module.clone(), item)),
|
||||
Err(e) => diags.push(CanonDiagnostic::error(format!(
|
||||
"Invalid import item '{}': {}",
|
||||
name_str, e
|
||||
))),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => diags.push(CanonDiagnostic::error(format!(
|
||||
"Invalid import path '{}': {}",
|
||||
&imp.from, e
|
||||
))),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare canonical exports from symbol tables (names only, kind best-effort)
|
||||
let mut exports: Vec<ExportItem> = Vec::new();
|
||||
|
||||
@@ -1322,12 +1322,9 @@ impl<'a> Lowerer<'a> {
|
||||
// Usar o binding real do import para este Service (ex.: Log -> (sdk, log))
|
||||
let obj_name_str = obj_name.to_string();
|
||||
if let Some((dep_alias, module_path)) = self.import_bindings.get(&obj_name_str).cloned() {
|
||||
// Determine the synthetic module path used when we synthesized dependency symbols
|
||||
// We support both styles: "alias/module" and "@alias:module"
|
||||
let synthetic_paths = [
|
||||
format!("{}/{}", dep_alias, module_path),
|
||||
format!("@{}:{}", dep_alias, module_path),
|
||||
];
|
||||
// Determine the canonical module origin used when we synthesized dependency symbols
|
||||
// Only supported style: "@alias:module"
|
||||
let canonical_origin = format!("@{}:{}", dep_alias, module_path);
|
||||
|
||||
// Find candidates among imported value symbols matching:
|
||||
// - name in the new canonical form: "Service.member#sigN" (prefix match on qualified base)
|
||||
@@ -1342,7 +1339,7 @@ impl<'a> Lowerer<'a> {
|
||||
let matches_legacy = sname.starts_with(&format!("{}#sig", member_name));
|
||||
if matches_qualified || matches_legacy {
|
||||
if let Some(orig) = &s.origin {
|
||||
if synthetic_paths.iter().any(|p| p == orig) {
|
||||
if *orig == canonical_origin {
|
||||
candidates.push(s);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user