Skip to content

compile: bare hasOwnProperty.call(...) (Object.prototype member via globalThis) throws 'value is not a function' — pi wall #6 #6652

Description

@proggeramlug

Wall #6 of the pi coding-agent bring-up (tracker #6564; prior: #6593, #6604, #6644, #6649, #6651 all fixed). With the five fixes applied, pi-native --help/--version die during module init with:

TypeError: value is not a function
    at pi-bundle.mjs:203852

(line resolved by a --debug-symbols build, dist/pi-native-dbg; the stripped build says at <anonymous>.)

Site: @babel/types/lib/definitions/placeholders.js (webpack-wrapped CJS factory in the bundle), pi-bundle.mjs:203852:

Object.keys(i2).forEach((e4) => {
  i2[e4].forEach((t4) => {
    hasOwnProperty.call(o, t4) || (o[t4] = []), o[t4].push(e4);   // ← line 203852
  });
});

Root cause / subsystem: the BARE identifier hasOwnProperty — Node resolves it through the scope chain to the global object, which inherits Object.prototype.hasOwnProperty, so hasOwnProperty.call(o, t4) works. Perry's unknown-identifier path (Warning: unknown identifier 'hasOwnProperty' — assuming global; member access will dispatch by name at runtime, bare reads lower to 0) does not serve Object.prototype-INHERITED members of the global object, so the .call member dispatch comes back non-callable and the call site throws. Not a module-resolution issue — the #6651 family is closed (the bundle's node:v8 / stream/web / fs/promises requires all resolve now).

3-line repro (node: bare: true false; perry: compile warning above + TypeError: value is not a function, rc=1):

const o: any = { x: 1 };
// bare global hasOwnProperty (inherited from Object.prototype via globalThis)
console.log("bare:", hasOwnProperty.call(o, "x"), hasOwnProperty.call(o, "y"));

Scope: grep -c "unknown identifier 'hasOwnProperty'" compile6651.log → 14 sites in the pi bundle (plus 2 bare-toString sites — same subsystem, likely walls #7-ish if fixed per-identifier; one fix for "assume-global member access must consult the global object's Object.prototype chain" should cover the whole class).

Repro binaries: secret-tests/pi-target/dist/pi-native (stripped, #6603+#6633+#6647+#6650+#6651 fixes) and pi-native-dbg (debug symbols, prints the bundle line); pi-native.pre6651 reproduces wall #5 for contrast. HOME=$(mktemp -d) ./pi-native --help.

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 regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions