oven-sh/bun · error · Error

Union type cannot include a default value. Instead, set a de

Error message

Union type cannot include a default value. Instead, set a default value on the union type itself

What it means

Error "Union type cannot include a default value. Instead, set a default value on the union type itself" thrown in oven-sh/bun.

Source

Thrown at src/codegen/bindgen-lib-internal.ts:664

  }
}

export function cAbiTypeForEnum(length: number): CAbiType {
  return ("u" + alignForward(length, 8)) as CAbiType;
}

export function inspect(value: any) {
  return Bun.inspect(value, { colors: Bun.enableANSIColors });
}

export function oneOfImpl(types: TypeImpl[]): TypeImpl {
  const out: TypeImpl[] = [];
  for (const type of types) {
    if (type.kind === "oneOf") {
      out.push(...type.data);
    } else {
      if (type.flags.default) {
        throw new Error(
          "Union type cannot include a default value. Instead, set a default value on the union type itself",
        );
      }
      if (type.isVirtualArgument()) {
        throw new Error(`t.${type.kind} can only be used as a function argument type`);
      }
      out.push(type);
    }
  }
  return new TypeImpl("oneOf", out);
}

export function dictionaryImpl(record: Record<string, TypeImpl>): TypeImpl {
  const out: DictionaryField[] = [];
  for (const key in record) {
    const type = record[key];
    if (type.isVirtualArgument()) {
      throw new Error(`t.${type.kind} can only be used as a function argument type`);

View on GitHub (pinned to 8c5296ac45)

When it happens

Trigger: Thrown at src/codegen/bindgen-lib-internal.ts:664 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/b63d40524b5bb787. Report an issue: GitHub.