fix: duplicate definition check in let-in

This commit is contained in:
2026-01-11 16:37:17 +08:00
parent c8e617fe24
commit 7d04d8262f

View File

@@ -414,9 +414,12 @@ where
}
ast::Entry::AttrpathValue(value) => {
let attrpath = value.attrpath().unwrap();
if let Some(first_attr) = attrpath.attrs().next()
&& let ast::Attr::Ident(ident) = first_attr
{
let attrs_vec: Vec<_> = attrpath.attrs().collect();
// Only check for duplicate definitions if this is a top-level binding (path length == 1)
// For nested paths (e.g., types.a, types.b), they will be merged into the same attrset
if attrs_vec.len() == 1 {
if let Some(ast::Attr::Ident(ident)) = attrs_vec.first() {
let sym = ctx.new_sym(ident.to_string());
if !binding_syms.insert(sym) {
return Err(Error::downgrade_error(format!(
@@ -425,6 +428,13 @@ where
)));
}
}
} else if attrs_vec.len() > 1 {
// For nested paths, just record the first-level name without checking duplicates
if let Some(ast::Attr::Ident(ident)) = attrs_vec.first() {
let sym = ctx.new_sym(ident.to_string());
binding_syms.insert(sym);
}
}
}
}
}