oven-sh/bun · error · Error
Duplicate private name
Error message
Duplicate private name "${name}" in BunBuiltinNames.h What it means
Consistency check in bundle-functions.ts: while generating BunBuiltinNames.h, a name newly produced from the builtins sources duplicates an existing entry in the BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME macro block. Duplicate macro(...) entries would break the generated header, so the generator aborts with the duplicated private name.
Solutions
- Reuse the existing private identifier instead of declaring a second one with the same name
- Rename the new private property so it no longer collides with the one already listed in BunBuiltinNames.h
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/codegen/bundle-functions.ts:808 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/c2988f579585e819.
Report an issue: GitHub.
Appendix: source
Thrown at src/codegen/bundle-functions.ts:808
"#define BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME",
);
let definedBuiltinNamesMacroEndI = BunBuiltinNamesHeader.indexOf(
"--- END of BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME ---",
);
const definedBuiltinNames = BunBuiltinNamesHeader.slice(definedBuiltinNamesStartI, definedBuiltinNamesMacroEndI)
.split("\n")
.map(x => x.trim())
.filter(x => x.startsWith("macro("))
.map(x => x.slice(x.indexOf("(") + 1, x.indexOf(")")))
.map(x => x.trim())
.sort();
const uniqueDefinedBuiltinNames = new Set();
for (let name of definedBuiltinNames) {
const prevSize = uniqueDefinedBuiltinNames.size;
uniqueDefinedBuiltinNames.add(name);
if (uniqueDefinedBuiltinNames.size === prevSize) {
throw new Error(`Duplicate private name "${name}" in BunBuiltinNames.h`);
}
}
for (let additionalPrivateName of additionalPrivateNames) {
if (uniqueDefinedBuiltinNames.has(additionalPrivateName)) {
additionalPrivateNames.delete(additionalPrivateName);
}
}
let additionalPrivateNamesHeader = `// Generated by ${import.meta.path}
#pragma once
#ifndef BUN_ADDITIONAL_BUILTIN_NAMES
#define BUN_ADDITIONAL_BUILTIN_NAMES(macro) \\
${Array.from(additionalPrivateNames)
.map(x => `macro(${x})`)
.join(" \\\n ")}
#endif
`;View on GitHub (pinned to 8c5296ac45)