fix: duplicate definition check in let-in
This commit is contained in:
@@ -414,9 +414,12 @@ where
|
|||||||
}
|
}
|
||||||
ast::Entry::AttrpathValue(value) => {
|
ast::Entry::AttrpathValue(value) => {
|
||||||
let attrpath = value.attrpath().unwrap();
|
let attrpath = value.attrpath().unwrap();
|
||||||
if let Some(first_attr) = attrpath.attrs().next()
|
let attrs_vec: Vec<_> = attrpath.attrs().collect();
|
||||||
&& let ast::Attr::Ident(ident) = first_attr
|
|
||||||
{
|
// 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());
|
let sym = ctx.new_sym(ident.to_string());
|
||||||
if !binding_syms.insert(sym) {
|
if !binding_syms.insert(sym) {
|
||||||
return Err(Error::downgrade_error(format!(
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user