Skip to content

JS: parameters of a this.x = function member are not shadowed, so passing one as an argument fabricates an indirect_call to any same-named function in the corpus #5241

Closed

Description

@laurism-openelms

Version: 0.9.111 (macOS, graphify extract . --code-only)

Related: #4448 and #5217 (both fixed). This is a third case in the same family that the #5221 fix does not cover.

Summary

A parameter of a function assigned to this.x inside a callback (the AngularJS service shape) is not shadowed. When the parameter is passed as a call argument, it resolves corpus-wide and binds to any function with the same name, even a non-exported function in a TypeScript file that nothing imports. The same function assigned to $scope.x instead of this.x is shadowed correctly.

Reproduction

app/service.js:

angular.module('app').service('$svc', function ($http) {
  var svc = this;
  // D: this.member param, passed to a bare call
  this.d = function (scope) { bare(scope); };
  // E: this.member param, passed to a member call
  this.e = function (scope, group) { this.defaults(scope, group); };
  // F: this.member param, passed to a call on a captured alias
  this.f = function (item) { return svc.selectable(item); };
});
angular.module('app').controller('Ctrl', function ($scope) {
  // control: the same shape on a $scope member is shadowed
  $scope.g = function (scope) { bare(scope); };
});

web/helpers.ts (not exported, not imported anywhere):

function scope(): number { return 1; }
function item(): number { return 2; }

Run graphify extract . --code-only, then list the indirect_call edges.

Expected

No indirect_call edges. scope and item are parameters of the functions that use them.

Actual

('indirect_call', 'INFERRED', 'd()', 'scope()', 'L4')
('indirect_call', 'INFERRED', 'e()', 'scope()', 'L6')
('indirect_call', 'INFERRED', 'f()', 'item()', 'L8')

The control case $scope.g gives no edge. The kind of call does not matter (bare, this.method() or a call on a captured alias). What matters is that the function is a this.x member, which is the form extracted as a node since #3408 (labelled d(), e(), f() here). It looks like the parameter scope of that node is not seeded before its body is resolved.

Impact

In a real codebase that mixes an AngularJS frontend with a separate TypeScript app, 21 cross-layer indirect_call edges remain after 0.9.110 (down from 55, thanks to #5221). Most of them sit in this.x members of AngularJS services and go to functions with generic names such as scope(), item() and value(). A few come from nearby forms that may share the cause: a parameter used as an object-literal value ({ comment: comment }) and a function assigned to a member of a local object (api.safeText = function (value) {...}).

Suggested direction

When a this.x = function (...) {} assignment becomes a member node, register its parameters as locals of that node, the same as for a function declaration or a $scope.x assignment, before its call arguments are resolved.

Activity

  1. github-actions commented on Nov 16, 2026

    @github-actions

    Thanks for opening this issue, @laurism-openelms. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions