diff --git a/nix-js/Cargo.toml b/nix-js/Cargo.toml index b4a63b3..6d560c0 100644 --- a/nix-js/Cargo.toml +++ b/nix-js/Cargo.toml @@ -11,14 +11,17 @@ mimalloc = "0.1" anyhow = "1.0" rustyline = "14.0" -regex = "1.11" -hashbrown = "0.16" derive_more = { version = "2", features = ["full"] } -thiserror = "2" -string-interner = "0.19" -itertools = "0.14" pin-project = "1" +hashbrown = "0.16" +string-interner = "0.19" + +thiserror = "2" +itertools = "0.14" + +regex = "1.11" + deno_core = "0.376" deno_error = "0.7" diff --git a/nix-js/src/ir/utils.rs b/nix-js/src/ir/utils.rs index 8624f96..1960339 100644 --- a/nix-js/src/ir/utils.rs +++ b/nix-js/src/ir/utils.rs @@ -242,7 +242,13 @@ where ast::Entry::Inherit(inherit) => { for attr in inherit.attrs() { if let ast::Attr::Ident(ident) = attr { - binding_syms.insert(ctx.new_sym(ident.to_string())); + 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)) + ))); + } } } } @@ -251,7 +257,13 @@ where if let Some(first_attr) = attrpath.attrs().next() && let ast::Attr::Ident(ident) = first_attr { - binding_syms.insert(ctx.new_sym(ident.to_string())); + 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)) + ))); + } } } }