Skip to content

compiler(bun): suppress unknown-identifier warnings for the provided Bun global #9745

Description

@proggeramlug

Problem

Bun-platform mode now provides the real globalThis.Bun namespace (#9599), and bare Bun resolves to it at runtime. The HIR diagnostic path still reports every bare use as an unknown identifier:

Warning: unknown identifier 'Bun' — assuming global; resolved by name on globalThis ...

Large Bun-target graphs can emit dozens of these false-positive warnings, obscuring actionable compatibility diagnostics.

Minimal repro

console.log(Bun === globalThis.Bun);
console.log(Bun.version);
console.log(typeof Bun.file);
perry compile main.js --platform bun -o app

The compile should not warn that Bun is unknown.

Acceptance criteria

  • In explicit Bun-platform mode, an unshadowed bare Bun is classified as a platform-provided global and emits no unknown-identifier warning.
  • It still lowers through the same runtime namespace introduced by bun-compat: add an opt-in Bun platform mode with a real globalThis.Bun namespace #9599.
  • A lexical binding named Bun shadows the platform global normally.
  • Non-Bun/default platform mode keeps its existing feature-detection and diagnostic behavior.
  • Other unknown identifiers are unaffected.
  • Tests cover bare reads, typeof Bun, computed access, destructuring, and shadowing in both platform modes.

This issue is diagnostic hygiene only; it does not add new Bun namespace members.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressiontoolingDeveloper tooling, CI, tests, or release infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions