@eagleoutice/flowr 2.10.6 → 2.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +8 -8
  2. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  3. package/dataflow/environments/built-in-proc-name.d.ts +22 -20
  4. package/dataflow/environments/built-in-proc-name.js +22 -20
  5. package/dataflow/environments/built-in.d.ts +19 -19
  6. package/dataflow/environments/identifier.d.ts +5 -0
  7. package/dataflow/environments/reference-to-maybe.js +32 -6
  8. package/dataflow/eval/resolve/alias-tracking.js +5 -0
  9. package/dataflow/graph/graph.js +51 -30
  10. package/dataflow/graph/vertex.d.ts +12 -11
  11. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +49 -12
  12. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -2
  13. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +12 -6
  14. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +22 -8
  15. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +57 -1
  16. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  17. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +7 -7
  18. package/linter/linter-format.d.ts +4 -0
  19. package/linter/linter-rules.d.ts +5 -5
  20. package/linter/rules/absolute-path.d.ts +0 -2
  21. package/linter/rules/dataframe-access-validation.d.ts +4 -7
  22. package/linter/rules/dataframe-access-validation.js +3 -3
  23. package/linter/rules/dead-code.d.ts +4 -7
  24. package/linter/rules/file-path-validity.d.ts +0 -2
  25. package/linter/rules/function-finder-util.d.ts +1 -3
  26. package/linter/rules/function-finder-util.js +2 -2
  27. package/linter/rules/naming-convention.d.ts +0 -2
  28. package/linter/rules/network-functions.js +4 -1
  29. package/linter/rules/problematic-inputs.d.ts +0 -2
  30. package/linter/rules/roxygen-arguments.d.ts +0 -2
  31. package/linter/rules/seeded-randomness.d.ts +0 -2
  32. package/linter/rules/stop-with-call-arg.d.ts +3 -6
  33. package/linter/rules/unused-definition.d.ts +0 -2
  34. package/linter/rules/useless-loop.d.ts +0 -2
  35. package/package.json +4 -4
  36. package/queries/catalog/dependencies-query/dependencies-query-executor.js +6 -2
  37. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
  38. package/queries/catalog/dependencies-query/function-info/source-functions.js +1 -1
  39. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
  40. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +16 -16
  41. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  42. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +8 -0
  43. package/search/flowr-search-builder.d.ts +16 -2
  44. package/search/flowr-search-builder.js +10 -1
  45. package/search/flowr-search.d.ts +9 -0
  46. package/search/search-executor/search-generators.d.ts +1 -1
  47. package/search/search-executor/search-generators.js +28 -2
  48. package/slicing/static/static-slicer.js +2 -2
  49. package/util/range.d.ts +13 -1
  50. package/util/range.js +32 -2
  51. package/util/version.js +1 -1
@@ -47,9 +47,7 @@ function findRootAccess(node) {
47
47
  if (current.type === type_1.RType.Symbol) {
48
48
  return current;
49
49
  }
50
- else {
51
- return undefined;
52
- }
50
+ return undefined;
53
51
  }
54
52
  function tryReplacement(rootId, functionName, data, name, args) {
55
53
  const resolved = (0, resolve_by_name_1.resolveByName)(functionName.content, data.environment, identifier_1.ReferenceType.Function) ?? [];
@@ -129,7 +127,7 @@ args, rootId, data, config) {
129
127
  data,
130
128
  reverseOrder: !config.swapSourceAndTarget,
131
129
  forceArgs: config.forceArgs,
132
- origin: built_in_proc_name_1.BuiltInProcName.Assignment
130
+ origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
133
131
  });
134
132
  return processAssignmentToSymbol({
135
133
  ...config,
@@ -155,7 +153,7 @@ args, rootId, data, config) {
155
153
  data,
156
154
  reverseOrder: !config.swapSourceAndTarget,
157
155
  forceArgs: config.forceArgs,
158
- origin: built_in_proc_name_1.BuiltInProcName.Assignment
156
+ origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
159
157
  });
160
158
  return processAssignmentToSymbol({
161
159
  ...config,
@@ -197,7 +195,7 @@ args, rootId, data, config) {
197
195
  data,
198
196
  reverseOrder: !config.swapSourceAndTarget,
199
197
  forceArgs: config.forceArgs,
200
- origin: built_in_proc_name_1.BuiltInProcName.Assignment
198
+ origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
201
199
  });
202
200
  return processAssignmentToSymbol({
203
201
  ...config,
@@ -217,7 +215,7 @@ args, rootId, data, config) {
217
215
  logger_1.dataflowLogger.warn(`Assignment ${identifier_1.Identifier.toString(name.content)} has an unknown target type ${target.type} => unknown impact`);
218
216
  const info = (0, known_call_handling_1.processKnownFunctionCall)({
219
217
  name, args: effectiveArgs, rootId, data, forceArgs: config.forceArgs,
220
- origin: built_in_proc_name_1.BuiltInProcName.Assignment
218
+ origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
221
219
  }).information;
222
220
  (0, unknown_side_effect_1.handleUnknownSideEffect)(info.graph, info.environment, rootId);
223
221
  return info;
@@ -267,7 +265,7 @@ function processAssignmentToString(target, args, name, rootId, data, config, sou
267
265
  data,
268
266
  reverseOrder: !config.swapSourceAndTarget,
269
267
  forceArgs: config.forceArgs,
270
- origin: built_in_proc_name_1.BuiltInProcName.Assignment
268
+ origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
271
269
  });
272
270
  return processAssignmentToSymbol({
273
271
  ...config,
@@ -326,14 +324,13 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
326
324
  return undefined;
327
325
  }
328
326
  const fieldName = (fieldNode.type === type_1.RType.String ? fieldNode.content.str : fieldNode.lexeme);
329
- /* run normal $<- replacement to get correct graph structure (reads of e, x, source) */
330
327
  const normalResult = tryReplacement(rootId, replacement, data, replacement.content, [(0, make_argument_1.toUnnamedArgument)(target.accessed, data.completeAst.idMap), ...target.access, source]);
331
328
  const fieldDef = {
332
329
  type: identifier_1.ReferenceType.Variable,
333
330
  name: fieldName,
334
331
  nodeId: fieldNode.info.id,
335
332
  definedAt: rootId,
336
- cds: data.cds
333
+ cds: data.cds ?? (config.makeMaybe ? [] : undefined)
337
334
  };
338
335
  const newEnvState = (0, define_1.define)(fieldDef, false, envirResolution.envDef.envState);
339
336
  const updatedEnvDef = {
@@ -345,6 +342,7 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
345
342
  current: normalResult.environment.current.removeAll([{ name: envirResolution.envDef.name }]),
346
343
  level: normalResult.environment.level
347
344
  };
345
+ normalResult.graph.addEdge(normalResult.entryPoint, target.accessed.info.id, edge_1.EdgeType.Reads);
348
346
  return { ...normalResult, environment: (0, define_1.define)(updatedEnvDef, false, strippedEnv) };
349
347
  }
350
348
  /**
@@ -415,18 +413,44 @@ function processAssignmentToSymbol(config) {
415
413
  : produceWrittenNodes(rootId, targetArg, referenceType, data, makeMaybe ?? false, aliases);
416
414
  if (data.ctx.config.solver.trackEnvironments) {
417
415
  let envState;
416
+ let returnsEnvState;
418
417
  if (isEnvCreatorSource(sourceArg)) {
419
418
  envState = (0, built_in_new_env_1.createFreshEnvState)(data, sourceArg);
420
419
  }
421
420
  else if (source.type === type_1.RType.Symbol) {
422
421
  const defs = (0, resolve_by_name_1.resolveByName)(source.content, data.environment, identifier_1.ReferenceType.Variable);
423
- envState = defs?.find(d => d.envState !== undefined)?.envState;
422
+ const def = defs?.find((d) => d.envState !== undefined);
423
+ envState = def?.envState;
424
+ if (!envState) {
425
+ const fnDef = defs?.find((d) => d.returnsEnvState !== undefined);
426
+ if (fnDef?.returnsEnvState) {
427
+ envState = fnDef.returnsEnvState;
428
+ }
429
+ }
430
+ }
431
+ else {
432
+ const entryVertex = sourceArg.graph.getVertex(sourceArg.entryPoint);
433
+ if ((0, vertex_1.isFunctionDefinitionVertex)(entryVertex) && entryVertex.returnEnvState !== undefined) {
434
+ returnsEnvState = entryVertex.returnEnvState;
435
+ }
436
+ else if ((0, vertex_1.isFunctionCallVertex)(entryVertex) && entryVertex.name) {
437
+ const fnDefs = (0, resolve_by_name_1.resolveByName)(entryVertex.name, data.environment, identifier_1.ReferenceType.Function);
438
+ const fnDef = fnDefs?.find((d) => d.returnsEnvState !== undefined);
439
+ if (fnDef?.returnsEnvState) {
440
+ envState = fnDef.returnsEnvState;
441
+ }
442
+ }
424
443
  }
425
444
  if (envState) {
426
445
  for (let i = 0; i < writeNodes.length; i++) {
427
446
  writeNodes[i] = { ...writeNodes[i], envState };
428
447
  }
429
448
  }
449
+ else if (returnsEnvState) {
450
+ for (let i = 0; i < writeNodes.length; i++) {
451
+ writeNodes[i] = { ...writeNodes[i], returnsEnvState };
452
+ }
453
+ }
430
454
  }
431
455
  if (writeNodes.length !== 1 && log_1.log.settings.minLevel >= 4 /* LogLevel.Warn */) {
432
456
  log_1.log.warn(`Unexpected write number in assignment: ${JSON.stringify(writeNodes)}`);
@@ -435,7 +459,20 @@ function processAssignmentToSymbol(config) {
435
459
  const readFromSourceWritten = sourceArg.out.slice(1);
436
460
  const readTargets = [
437
461
  { nodeId: rootId, name: nameOfAssignmentFunction, cds: data.cds, type: identifier_1.ReferenceType.Function }
438
- ].concat(sourceArg.unknownReferences, sourceArg.in, targetName ? targetArg.in : targetArg.in.filter(i => i.nodeId !== targetId), readFromSourceWritten);
462
+ ];
463
+ readTargets.push(...sourceArg.unknownReferences);
464
+ readTargets.push(...sourceArg.in);
465
+ if (targetName) {
466
+ readTargets.push(...targetArg.in);
467
+ }
468
+ else {
469
+ for (const i of targetArg.in) {
470
+ if (i.nodeId !== targetId) {
471
+ readTargets.push(i);
472
+ }
473
+ }
474
+ }
475
+ readTargets.push(...readFromSourceWritten);
439
476
  information.environment = (0, overwrite_1.overwriteEnvironment)(sourceArg.environment, targetArg.environment);
440
477
  // install assigned variables in environment
441
478
  for (const write of writeNodes) {
@@ -7,7 +7,9 @@ import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/proce
7
7
  /**
8
8
  * Processes `attach(what, ...)` - when `what` is a variable that holds a tracked
9
9
  * {@link InGraphIdentifierDefinition#envState}, all statically-known definitions from
10
- * that environment are injected into the current scope so that subsequent reads of
11
- * those names resolve correctly.
10
+ * that environment are injected into a new scope layer inserted *between* the current
11
+ * scope and its parent. This mirrors R's behaviour: `attach` adds to the search path
12
+ * below `.GlobalEnv`, so existing global bindings take precedence, but after a
13
+ * `rm(name)` removes a global shadow the attached binding becomes visible again.
12
14
  */
13
15
  export declare function processAttach<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -6,7 +6,7 @@ const unpack_argument_1 = require("../argument/unpack-argument");
6
6
  const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
7
7
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
8
8
  const identifier_1 = require("../../../../../environments/identifier");
9
- const define_1 = require("../../../../../environments/define");
9
+ const environment_1 = require("../../../../../environments/environment");
10
10
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
11
11
  const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
12
12
  const edge_1 = require("../../../../../graph/edge");
@@ -14,8 +14,10 @@ const built_in_envir_utils_1 = require("./built-in-envir-utils");
14
14
  /**
15
15
  * Processes `attach(what, ...)` - when `what` is a variable that holds a tracked
16
16
  * {@link InGraphIdentifierDefinition#envState}, all statically-known definitions from
17
- * that environment are injected into the current scope so that subsequent reads of
18
- * those names resolve correctly.
17
+ * that environment are injected into a new scope layer inserted *between* the current
18
+ * scope and its parent. This mirrors R's behaviour: `attach` adds to the search path
19
+ * below `.GlobalEnv`, so existing global bindings take precedence, but after a
20
+ * `rm(name)` removes a global shadow the attached binding becomes visible again.
19
21
  */
20
22
  function processAttach(name, args, rootId, data) {
21
23
  const result = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Attach }).information;
@@ -30,7 +32,8 @@ function processAttach(name, args, rootId, data) {
30
32
  (0, unknown_side_effect_1.handleUnknownSideEffect)(result.graph, result.environment, rootId);
31
33
  return result;
32
34
  }
33
- let newEnvironment = result.environment;
35
+ /* build the attached layer with the env's known bindings */
36
+ let attachedLayer = new environment_1.Environment(result.environment.current.parent);
34
37
  for (const [varName, varDefs] of envirResolution.envDef.envState.current.memory) {
35
38
  for (const varDef of varDefs) {
36
39
  const inDef = varDef;
@@ -39,10 +42,13 @@ function processAttach(name, args, rootId, data) {
39
42
  name: varName,
40
43
  type: identifier_1.ReferenceType.Variable,
41
44
  };
42
- newEnvironment = (0, define_1.define)(injected, false, newEnvironment);
45
+ attachedLayer = attachedLayer.define(injected);
43
46
  result.graph.addEdge(inDef.nodeId, rootId, edge_1.EdgeType.Reads);
44
47
  }
45
48
  }
46
- return { ...result, environment: newEnvironment };
49
+ /* splice the attached layer between the current scope and its original parent */
50
+ const newCurrent = result.environment.current.clone(false);
51
+ newCurrent.parent = attachedLayer;
52
+ return { ...result, environment: { current: newCurrent, level: result.environment.level } };
47
53
  }
48
54
  //# sourceMappingURL=built-in-attach.js.map
@@ -19,6 +19,7 @@ const logger_1 = require("../../../../../logger");
19
19
  const log_1 = require("../../../../../../util/log");
20
20
  const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
21
21
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
22
+ const general_1 = require("../../../../../eval/values/general");
22
23
  function linkReadNameToWriteIfPossible(read, environments, listEnvironments, remainingRead, nextGraph) {
23
24
  const readName = read.name && identifier_1.Identifier.isDotDotDotAccess(read.name) ? identifier_1.Identifier.dotdotdot() : read.name;
24
25
  const probableTarget = readName ? (0, resolve_by_name_1.resolveByName)(readName, environments, read.type) : undefined;
@@ -41,14 +42,23 @@ function linkReadNameToWriteIfPossible(read, environments, listEnvironments, rem
41
42
  return;
42
43
  }
43
44
  const rid = read.nodeId;
45
+ const isFunc = read.type === identifier_1.ReferenceType.Function || read.type === identifier_1.ReferenceType.BuiltInFunction;
44
46
  for (const target of probableTarget) {
45
47
  const tid = target.nodeId;
46
- if (node_id_1.NodeId.isBuiltIn(target.definedAt) && (read.type === identifier_1.ReferenceType.Function || read.type === identifier_1.ReferenceType.BuiltInFunction)) {
48
+ if (node_id_1.NodeId.isBuiltIn(target.definedAt) && isFunc) {
47
49
  nextGraph.addEdge(rid, tid, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
48
50
  }
49
51
  else {
50
52
  nextGraph.addEdge(rid, tid, edge_1.EdgeType.Reads);
51
53
  }
54
+ if (target.type === identifier_1.ReferenceType.BuiltInConstant) {
55
+ nextGraph.addVertex({
56
+ tag: vertex_1.VertexType.Value,
57
+ id: tid,
58
+ cds: undefined,
59
+ value: (0, general_1.valueFromTsValue)(target.value)
60
+ }, environments, false);
61
+ }
52
62
  }
53
63
  }
54
64
  function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextGraph, localDefs) {
@@ -104,7 +114,7 @@ function processExpressionList(name, args, rootId, data) {
104
114
  const listEnvironments = new Set();
105
115
  const remainingRead = new Map();
106
116
  const nextGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
107
- let out = [];
117
+ const out = [];
108
118
  const exitPoints = [];
109
119
  const activeCdsAtStart = data.cds;
110
120
  const invertExitCds = [];
@@ -128,12 +138,13 @@ function processExpressionList(name, args, rootId, data) {
128
138
  processed.in = (0, reference_to_maybe_1.makeAllMaybe)(processed.in, nextGraph, processed.environment, false, invertExitCds);
129
139
  processed.unknownReferences = (0, reference_to_maybe_1.makeAllMaybe)(processed.unknownReferences, nextGraph, processed.environment, false);
130
140
  }
131
- out = out.concat(processed.out);
141
+ out.push(...processed.out);
132
142
  // all inputs that have not been written until now are read!
133
- for (const ls of [processed.in, processed.unknownReferences]) {
134
- for (const read of ls) {
135
- linkReadNameToWriteIfPossible(read, environment, listEnvironments, remainingRead, nextGraph);
136
- }
143
+ for (const read of processed.in) {
144
+ linkReadNameToWriteIfPossible(read, environment, listEnvironments, remainingRead, nextGraph);
145
+ }
146
+ for (const read of processed.unknownReferences) {
147
+ linkReadNameToWriteIfPossible(read, environment, listEnvironments, remainingRead, nextGraph);
137
148
  }
138
149
  const calledEnvs = (0, linker_1.linkFunctionCalls)(nextGraph, data.completeAst.idMap, processed.graph);
139
150
  for (const c of calledEnvs) {
@@ -167,7 +178,10 @@ function processExpressionList(name, args, rootId, data) {
167
178
  nodeId: defaultReturnExpr.entryPoint
168
179
  });
169
180
  }
170
- const ingoing = remainingRead.values().toArray().flat();
181
+ const ingoing = [];
182
+ for (const refs of remainingRead.values()) {
183
+ ingoing.push(...refs);
184
+ }
171
185
  const rootNode = data.completeAst.idMap.get(rootId);
172
186
  const withGroup = rootNode?.grouping;
173
187
  if (withGroup) {
@@ -16,6 +16,7 @@ const graph_1 = require("../../../../../graph/graph");
16
16
  const identifier_1 = require("../../../../../environments/identifier");
17
17
  const overwrite_1 = require("../../../../../environments/overwrite");
18
18
  const vertex_1 = require("../../../../../graph/vertex");
19
+ const built_in_new_env_1 = require("./built-in-new-env");
19
20
  const scoping_1 = require("../../../../../environments/scoping");
20
21
  const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
21
22
  const edge_1 = require("../../../../../graph/edge");
@@ -128,6 +129,25 @@ function processFunctionDefinition(name, args, rootId, data) {
128
129
  afterHookExitPoints = (0, info_1.overwriteExitPoints)(afterHookExitPoints, hookExitPoints);
129
130
  }
130
131
  }
132
+ let returnEnvState;
133
+ if (data.ctx.config.solver.trackEnvironments) {
134
+ for (const ep of afterHookExitPoints) {
135
+ const epVertex = subgraph.getVertex(ep.nodeId);
136
+ if ((0, vertex_1.isFunctionCallVertex)(epVertex) && epVertex.origin.includes(built_in_proc_name_1.BuiltInProcName.NewEnv)) {
137
+ returnEnvState = (0, built_in_new_env_1.createFreshEnvState)(data, { graph: subgraph, entryPoint: ep.nodeId });
138
+ break;
139
+ }
140
+ const epNode = subgraph.idMap?.get(ep.nodeId);
141
+ if (epNode?.type === type_1.RType.Symbol) {
142
+ const defs = (0, resolve_by_name_1.resolveByName)(epNode.content, outEnvironment, identifier_1.ReferenceType.Variable);
143
+ const def = defs?.find((d) => d.envState !== undefined);
144
+ if (def?.envState) {
145
+ returnEnvState = def.envState;
146
+ break;
147
+ }
148
+ }
149
+ }
150
+ }
131
151
  const graph = new graph_1.DataflowGraph(data.completeAst.idMap).mergeWith(subgraph, false);
132
152
  graph.addVertex({
133
153
  tag: vertex_1.VertexType.FunctionDefinition,
@@ -136,7 +156,8 @@ function processFunctionDefinition(name, args, rootId, data) {
136
156
  cds: data.cds,
137
157
  params: readParams,
138
158
  subflow: flow,
139
- exitPoints: afterHookExitPoints
159
+ exitPoints: afterHookExitPoints,
160
+ returnEnvState
140
161
  }, data.ctx.env.makeCleanEnv());
141
162
  return {
142
163
  /* nothing escapes a function definition, but the function itself, will be forced in assignment: { nodeId: functionDefinition.info.id, scope: data.activeScope, used: 'always', name: functionDefinition.info.id as string } */
@@ -220,6 +241,41 @@ function updateNestedFunctionClosures(graph, outEnvironment, fnId) {
220
241
  }
221
242
  (0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Keeping ${remainingIn.length} references to open ref ${id} in closure of function definition ${fnId}`);
222
243
  subflow.in = remainingIn;
244
+ linkSuperAssignmentsToOuterDefinitions(graph, subflow.graph, outEnvironment);
245
+ }
246
+ }
247
+ function linkSuperAssignmentsToOuterDefinitions(parentGraph, nestedGraphNodeIds, parentEnvironment) {
248
+ for (const nodeId of nestedGraphNodeIds) {
249
+ const vertex = parentGraph.getVertex(nodeId);
250
+ if (vertex?.tag !== vertex_1.VertexType.FunctionCall || !vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.SuperAssignment)) {
251
+ continue;
252
+ }
253
+ const outgoingReturns = parentGraph.outgoingEdges(nodeId);
254
+ if (!outgoingReturns) {
255
+ continue;
256
+ }
257
+ for (const [targetId, edge] of outgoingReturns) {
258
+ if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Returns)) {
259
+ continue;
260
+ }
261
+ const targetVertex = parentGraph.getVertex(targetId);
262
+ if (targetVertex?.tag !== vertex_1.VertexType.VariableDefinition) {
263
+ continue;
264
+ }
265
+ const targetNode = parentGraph.idMap?.get(targetId);
266
+ if (targetNode?.type !== type_1.RType.Symbol) {
267
+ continue;
268
+ }
269
+ const varName = targetNode.content;
270
+ const resolved = (0, resolve_by_name_1.resolveByName)(varName, parentEnvironment, identifier_1.ReferenceType.Variable);
271
+ if (resolved) {
272
+ for (const ref of resolved) {
273
+ if (ref.nodeId !== targetId && !node_id_1.NodeId.isBuiltIn(ref.nodeId)) {
274
+ parentGraph.addEdge(targetId, ref.nodeId, edge_1.EdgeType.Reads);
275
+ }
276
+ }
277
+ }
278
+ }
223
279
  }
224
280
  }
225
281
  /**
@@ -24,4 +24,4 @@ export declare function processNewEnv<OtherInfo>(name: RSymbol<OtherInfo & Paren
24
24
  * is honoured. Without `sourceInfo` (or when no `newEnvParent` is present), falls back
25
25
  * to the current execution environment as parent.
26
26
  */
27
- export declare function createFreshEnvState(data: Pick<DataflowProcessorInformation<never>, 'environment'>, sourceInfo?: DataflowInformation): REnvironmentInformation;
27
+ export declare function createFreshEnvState(data: Pick<DataflowProcessorInformation<never>, 'environment'>, sourceInfo?: Pick<DataflowInformation, 'graph' | 'entryPoint'>): REnvironmentInformation;
@@ -79,7 +79,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
79
79
  content: 'fun',
80
80
  info: {
81
81
  id: argNameId,
82
- nesting: name.info.nesting,
82
+ nest: name.info.nest,
83
83
  role: "arg-n" /* RoleInParent.ArgumentName */,
84
84
  fullRange: r,
85
85
  adToks: undefined,
@@ -96,7 +96,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
96
96
  lexeme: 'S7_dispatch',
97
97
  info: {
98
98
  id: funcNameId,
99
- nesting: name.info.nesting,
99
+ nest: name.info.nest,
100
100
  role: "call-name" /* RoleInParent.FunctionCallName */,
101
101
  fullRange: r,
102
102
  adToks: undefined,
@@ -116,7 +116,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
116
116
  arguments: [],
117
117
  info: {
118
118
  id: rootId + '-s7-new-generic-fun-body',
119
- nesting: name.info.nesting,
119
+ nest: name.info.nest,
120
120
  role: "fun-b" /* RoleInParent.FunctionDefinitionBody */,
121
121
  fullRange: r,
122
122
  adToks: undefined,
@@ -131,7 +131,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
131
131
  info: {
132
132
  file: name.info.file,
133
133
  id: fdefId,
134
- nesting: name.info.nesting,
134
+ nest: name.info.nest,
135
135
  role: "arg-v" /* RoleInParent.ArgumentValue */,
136
136
  parent: rootId,
137
137
  index: args + 1,
@@ -149,7 +149,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
149
149
  content: n,
150
150
  info: {
151
151
  id: paramNameId,
152
- nesting: name.info.nesting,
152
+ nest: name.info.nest,
153
153
  role: "param-n" /* RoleInParent.ParameterName */,
154
154
  fullRange: r,
155
155
  adToks: undefined,
@@ -168,7 +168,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
168
168
  special: n === '...',
169
169
  info: {
170
170
  id: paramId,
171
- nesting: name.info.nesting,
171
+ nest: name.info.nest,
172
172
  role: "param" /* RoleInParent.FunctionDefinitionParameter */,
173
173
  parent: fdefId,
174
174
  index: i,
@@ -193,7 +193,7 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
193
193
  location: r,
194
194
  info: {
195
195
  id: argId,
196
- nesting: name.info.nesting,
196
+ nest: name.info.nest,
197
197
  role: "call-arg" /* RoleInParent.FunctionCallArgument */,
198
198
  fullRange: r,
199
199
  adToks: undefined,
@@ -105,6 +105,10 @@ export interface LintingResult {
105
105
  * The node ID or IDs involved in this linting result, if applicable.
106
106
  */
107
107
  readonly involvedId: NodeId | NodeId[] | undefined;
108
+ /**
109
+ * The source location where this linting result occurs
110
+ */
111
+ readonly loc: SourceLocation;
108
112
  }
109
113
  export interface ConfiguredLintingRule<Name extends LintingRuleNames = LintingRuleNames> {
110
114
  readonly name: Name;
@@ -234,12 +234,12 @@ export declare const LintingRules: {
234
234
  cfg: import("../control-flow/control-flow-graph").ControlFlowInformation;
235
235
  analyzer: import("../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
236
236
  }) => {
237
- results: import("./rules/dead-code").DeadCodeResult[];
237
+ results: import("./linter-format").LintingResult[];
238
238
  '.meta': import("./rules/dead-code").DeadCodeMetadata;
239
239
  };
240
240
  readonly prettyPrint: {
241
- readonly query: (result: import("./rules/dead-code").DeadCodeResult) => string;
242
- readonly full: (result: import("./rules/dead-code").DeadCodeResult) => string;
241
+ readonly query: (result: import("./linter-format").LintingResult) => string;
242
+ readonly full: (result: import("./linter-format").LintingResult) => string;
243
243
  };
244
244
  readonly info: {
245
245
  readonly name: "Dead Code";
@@ -319,8 +319,8 @@ export declare const LintingRules: {
319
319
  '.meta': import("./rules/stop-with-call-arg").StopWithCallMetadata;
320
320
  };
321
321
  readonly prettyPrint: {
322
- readonly query: (result: import("./rules/stop-with-call-arg").StopWithCallResult) => string;
323
- readonly full: (result: import("./rules/stop-with-call-arg").StopWithCallResult) => string;
322
+ readonly query: (result: import("./linter-format").LintingResult) => string;
323
+ readonly full: (result: import("./linter-format").LintingResult) => string;
324
324
  };
325
325
  readonly info: {
326
326
  readonly name: "Stop without call.=False argument";
@@ -1,11 +1,9 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
2
  import { type MergeableRecord } from '../../util/objects';
3
- import { SourceLocation } from '../../util/range';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
6
5
  export interface AbsoluteFilePathResult extends LintingResult {
7
6
  filePath: string;
8
- loc: SourceLocation;
9
7
  }
10
8
  type SupportedWd = '@script' | '@home' | string;
11
9
  export interface AbsoluteFilePathConfig extends MergeableRecord {
@@ -1,20 +1,17 @@
1
1
  import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
2
  import type { FlowrSearchElements } from '../../search/flowr-search';
3
3
  import { type MergeableRecord } from '../../util/objects';
4
- import { SourceRange } from '../../util/range';
5
4
  import { LintingRuleCertainty, type LintingResult } from '../linter-format';
6
5
  import { LintingRuleTag } from '../linter-tags';
7
6
  export interface DataFrameAccessValidationResult extends LintingResult {
8
7
  /** The type of the data frame access ("column" or "row") */
9
- type: 'column' | 'row';
8
+ readonly type: 'column' | 'row';
10
9
  /** The name or index of the column or row being accessed in the data frame */
11
- accessed: string | number;
10
+ readonly accessed: string | number;
12
11
  /** The name of the function/operation used for the access (e.g. `$`, `[`, `[[`, but also `filter`, `select`, ...) */
13
- access: string;
12
+ readonly access: string;
14
13
  /** The variable/symbol name of the accessed data frame operand (`undefined` if operand is no symbol) */
15
- operand?: string;
16
- /** The source range in the code where the access occurs */
17
- range: SourceRange;
14
+ readonly operand?: string;
18
15
  }
19
16
  export interface DataFrameAccessValidationConfig extends MergeableRecord {
20
17
  /** Whether data frame shapes should be extracted from loaded external data files, such as CSV files (defaults to the option in the flowR config if `undefined`) */
@@ -67,7 +67,7 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
67
67
  involvedId: node?.info.id,
68
68
  access: node?.lexeme ?? '???',
69
69
  ...(operand?.type === type_1.RType.Symbol ? { operand: identifier_1.Identifier.getName(operand.content) } : {}),
70
- range: range_1.SourceRange.fromNode(node) ?? range_1.SourceRange.invalid(),
70
+ loc: range_1.SourceLocation.fromNode(node) ?? range_1.SourceLocation.invalid(),
71
71
  certainty: linter_format_1.LintingResultCertainty.Certain
72
72
  }));
73
73
  return { results, '.meta': metadata };
@@ -75,10 +75,10 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
75
75
  prettyPrint: {
76
76
  [linter_format_1.LintingPrettyPrintContext.Query]: result => `Access of ${result.type} ` +
77
77
  (typeof result.accessed === 'string' ? `"${result.accessed}"` : result.accessed) + ' ' +
78
- (result.operand === undefined ? `at \`${result.access}\`` : `of \`${result.operand}\``) + ` at ${range_1.SourceRange.format(result.range)}`,
78
+ (result.operand === undefined ? `at \`${result.access}\`` : `of \`${result.operand}\``) + ` at ${range_1.SourceLocation.format(result.loc)}`,
79
79
  [linter_format_1.LintingPrettyPrintContext.Full]: result => `Accessed ${result.type} ` +
80
80
  (typeof result.accessed === 'string' ? `"${result.accessed}"` : result.accessed) + ' does not exist ' +
81
- (result.operand === undefined ? `at \`${result.access}\`` : `in \`${result.operand}\``) + ` at ${range_1.SourceRange.format(result.range)}`
81
+ (result.operand === undefined ? `at \`${result.access}\`` : `in \`${result.operand}\``) + ` at ${range_1.SourceLocation.format(result.loc)}`
82
82
  },
83
83
  info: {
84
84
  name: 'Dataframe Access Validation',
@@ -1,11 +1,8 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
- import { SourceLocation } from '../../util/range';
3
2
  import type { MergeableRecord } from '../../util/objects';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import { type CfgSimplificationPassName } from '../../control-flow/cfg-simplification';
6
- export interface DeadCodeResult extends LintingResult {
7
- readonly loc: SourceLocation;
8
- }
5
+ export type DeadCodeResult = LintingResult;
9
6
  export interface DeadCodeConfig extends MergeableRecord {
10
7
  /**
11
8
  * The simplification passes that should be run on the extracted CFG.
@@ -24,12 +21,12 @@ export declare const DEAD_CODE: {
24
21
  cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
25
22
  analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
26
23
  }) => {
27
- results: DeadCodeResult[];
24
+ results: LintingResult[];
28
25
  '.meta': DeadCodeMetadata;
29
26
  };
30
27
  readonly prettyPrint: {
31
- readonly query: (result: DeadCodeResult) => string;
32
- readonly full: (result: DeadCodeResult) => string;
28
+ readonly query: (result: LintingResult) => string;
29
+ readonly full: (result: LintingResult) => string;
33
30
  };
34
31
  readonly info: {
35
32
  readonly name: "Dead Code";
@@ -1,11 +1,9 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
2
  import type { MergeableRecord } from '../../util/objects';
3
- import { SourceLocation } from '../../util/range';
4
3
  import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
5
4
  import { LintingRuleTag } from '../linter-tags';
6
5
  export interface FilePathValidityResult extends LintingResult {
7
6
  filePath: string;
8
- loc: SourceLocation;
9
7
  }
10
8
  export interface FilePathValidityConfig extends MergeableRecord {
11
9
  /**
@@ -1,4 +1,3 @@
1
- import { SourceLocation } from '../../util/range';
2
1
  import { type LintingResult, LintingResultCertainty } from '../linter-format';
3
2
  import type { FlowrSearchElement, FlowrSearchElements } from '../../search/flowr-search';
4
3
  import type { NormalizedAst, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
@@ -9,7 +8,6 @@ import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer
9
8
  import { Ternary } from '../../util/logic';
10
9
  export interface FunctionsResult extends LintingResult {
11
10
  function: string;
12
- loc: SourceLocation;
13
11
  }
14
12
  export interface FunctionsMetadata extends MergeableRecord {
15
13
  totalCalls: number;
@@ -36,7 +34,7 @@ export declare const functionFinderUtil: {
36
34
  query: (result: FunctionsResult) => string;
37
35
  full: (result: FunctionsResult) => string;
38
36
  };
39
- requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: readonly FunctionInfo[], data: {
37
+ requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, data: {
40
38
  normalize: NormalizedAst;
41
39
  dataflow: DataflowInformation;
42
40
  analyzer: ReadonlyFlowrAnalysisProvider;
@@ -61,7 +61,7 @@ exports.functionFinderUtil = {
61
61
  };
62
62
  },
63
63
  requireArgumentValue(element, pool, data, requireValue) {
64
- const info = pool.find(f => f.name === element.node.lexeme);
64
+ const info = pool.get(element.node.lexeme ?? '');
65
65
  /* if we have no additional info, we assume they always access the network */
66
66
  if (info === undefined) {
67
67
  return logic_1.Ternary.Always;
@@ -70,7 +70,7 @@ exports.functionFinderUtil = {
70
70
  if ((0, vertex_1.isFunctionCallVertex)(vert)) {
71
71
  const args = (0, resolve_argument_1.getArgumentStringValue)(data.analyzer.flowrConfig.solver.variables, data.dataflow.graph, vert, info.argIdx, info.argName, info.resolveValue, data.analyzer.inspectContext());
72
72
  // we obtain all values, at least one of them has to trigger for the request
73
- const argValues = args ? args.values().flatMap(v => [...v]).filter(assert_1.isNotUndefined).toArray() : [];
73
+ const argValues = args ? args.values().flatMap(s => Array.from(s)).filter(assert_1.isNotUndefined).toArray() : [];
74
74
  if (argValues.length === 0) {
75
75
  return logic_1.Ternary.Maybe;
76
76
  }
@@ -1,7 +1,6 @@
1
1
  import type { DataflowGraph } from '../../dataflow/graph/graph';
2
2
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  import type { MergeableRecord } from '../../util/objects';
4
- import { SourceLocation } from '../../util/range';
5
4
  import { type LintingResult, type LintQuickFixReplacement, LintingRuleCertainty } from '../linter-format';
6
5
  import { LintingRuleTag } from '../linter-tags';
7
6
  export declare enum CasingConvention {
@@ -16,7 +15,6 @@ export declare enum CasingConvention {
16
15
  export interface NamingConventionResult extends LintingResult {
17
16
  name: string;
18
17
  detectedCasing: CasingConvention;
19
- loc: SourceLocation;
20
18
  }
21
19
  /**
22
20
  * It is planned to have a config like ESLint