fix: duplicate definition check in let-in
This commit is contained in:
@@ -414,15 +414,25 @@ 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 sym = ctx.new_sym(ident.to_string());
|
||||
if !binding_syms.insert(sym) {
|
||||
return Err(Error::downgrade_error(format!(
|
||||
"attribute '{}' already defined",
|
||||
format_symbol(ctx.get_sym(sym))
|
||||
)));
|
||||
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!(
|
||||
"attribute '{}' already defined",
|
||||
format_symbol(ctx.get_sym(sym))
|
||||
)));
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user