Files
codegraph/__tests__/fixtures/kernel-parity/torture.js
T
bb1d3093eb fix(extraction): never fabricate an edge from a call-result receiver (#1748)
A member call whose receiver is itself a call — `d.setdefault(k, []).append(v)`,
`make().run()` — used to drop the receiver at extraction time, degrade to the
bare method name, and exact-match any top-level project symbol of that name
(Python and JavaScript/TypeScript). Keep the inner callee encoded as
`<inner>().<method>` in the TS extractor and native kernel; the name-matcher
refuses to guess for that shape (store-accessor exception only). Based on
#1692, rebased onto main after #1746. Fixes #1683.

Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
2026-09-08 00:23:08 -05:00

85 lines
1.7 KiB
JavaScript

/**
* JS-grammar torture fixture (javascript variant: no type machinery, JS class
* fields use `field_definition` with a `property` field).
*/
import { EventEmitter } from 'node:events';
const { promisify } = require('node:util');
/** Legacy prototype-style helper. */
function legacyHelper(a, b) {
return a + b;
}
const arrow = (x) => legacyHelper(x, 1);
class Widget extends EventEmitter {
static registry = new Map();
#privateField = 1;
label = 'w';
onTick = () => {
this.render();
};
wrapped = debounce(function () {
expensive();
}, 50);
constructor(opts) {
super();
this.opts = opts;
register(this.onTick);
}
render() {
paint(this.label);
}
static create(opts) {
return new Widget(opts);
}
}
// AMD-style wrapper — anonymous, but inner functions must still surface.
(function () {
function hiddenInner() {
return 7;
}
hiddenInner();
})();
module.exports.makeWidget = function makeWidget(opts) {
return Widget.create(opts);
};
// Vuex module shape (store-file signals: mutations + actions + getters).
const mutations = {
SET_USER(state, user) {
state.user = user;
},
};
const actions = {
async loadUser({ commit }, id) {
const user = await fetchUser(id);
commit('SET_USER', user);
},
};
export default {
namespaced: true,
state: () => ({ user: null }),
mutations,
actions,
getters: {
userName(state) {
return state.user?.name;
},
},
};
// --- call-expression receivers (#1683) ----------------------------------------
function bucketChains(d, k, v) {
d.setdefault(k, []).append(v);
make().run();
(0, make)().run();
arr[0]().go();
obj.make().run().again();
}