Skip to content

JS: this.X = function is extracted only inside a function *declaration* — every function-expression form drops it (incomplete fix of #1322) #3408

Closed

Description

@laurism-openelms

Title: JS: this.X = function is extracted only inside a function declaration — every function-expression form drops it (incomplete fix of #1322)

Summary

#1322 listed this.x = function(){} "inside any function body" and was closed. In 0.9.56 only one enclosing form works: a named function declaration. If the enclosing function is an expression — assigned to a const, an arrow, an IIFE, or a callback argument — the member is silently dropped.

The callback-argument case is the AngularJS service pattern, so an AngularJS frontend extracts to file nodes only.

Repro

// p2.js
function DeclFn(){ this.inDecl = function(){ return 1; }; }
const AnonToConst = function(){ this.inAnonConst = function(){ return 2; }; };
const ArrowToConst = () => { this.inArrow = function(){ return 3; }; };
callIt(function(){ this.inCallbackArg = function(){ return 4; }; });
(function(){ this.inIIFE = function(){ return 5; }; })();

graphify update . produces:

.inDecl()        <-- only this one
AnonToConst()
ArrowToConst()
DeclFn()
p2.js
enclosing function result
function DeclFn(){} declaration extracted
const A = function(){} missing
const A = () => {} missing
callIt(function(){}) missing
(function(){})() missing

Framework form this hits

angular.module('myApp').service('$thingService', function ($rootScope, $http) {
	this.loadThing = function (id) { /* ... */ };
	this.saveThing = function (thing) { /* ... */ };
});

A service file with 16 such members yields 0 nodes for them. A named function foo(){} declared inside the same callback is extracted, so the callback body is walked — only the this.X assignment is dropped.

Expected

A node per member, contained by the enclosing function, in every enclosing form. Per #3338, _js_member_assignment_target materializes only exports.X and Foo.prototype.X and other receivers are dropped by the #1077 guard, so this inside a function expression may just need adding to that allowlist alongside the window/globalThis work.

Impact

Measured on one private AngularJS + PHP codebase, 0.9.56, fully rebuilt:

layer files nodes avg/file contributing only the file node
PHP class layer 844 7913 9.4 1 (0%)
AngularJS frontend 661 1053 1.6 573 (87%)

The class layer extracts essentially completely. The frontend is opaque below file level, so the graph cannot answer "where is this behaviour implemented" for any of it.

Related

#1322 (closed, declaration case only), #2419/#2433 (object-literal shorthand), #3337/#3338 (window/globalThis receiver). Same family, different receiver and enclosing form.

Environment

graphify 0.9.56, macOS 15 (arm64), installed via uv tool install graphifyy.

Activity

  1. safishamsi commented on Sep 9, 2026

    @safishamsi
    Member

    Fixed in v0.9.57 by #3423 (thanks @abhay-codes07) — this.X = function members captured in every enclosing-function form. Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.57

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