@eagleoutice/flowr 2.17.1 → 2.17.3

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 (90) hide show
  1. package/README.md +9 -9
  2. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  3. package/data/r-reexports.generated.d.ts +4 -0
  4. package/data/r-reexports.generated.js +43 -0
  5. package/dataflow/environments/ambient-state-name.d.ts +4 -0
  6. package/dataflow/environments/ambient-state-name.js +4 -0
  7. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  8. package/dataflow/environments/built-in-proc-name.js +4 -0
  9. package/dataflow/environments/built-in-props.d.ts +2 -0
  10. package/dataflow/environments/built-in-props.js +3 -1
  11. package/dataflow/environments/built-in.d.ts +16 -6
  12. package/dataflow/environments/built-in.js +45 -4
  13. package/dataflow/environments/default-builtin-config.d.ts +846 -21
  14. package/dataflow/environments/default-builtin-config.js +120 -26
  15. package/dataflow/environments/environment.d.ts +19 -2
  16. package/dataflow/environments/environment.js +90 -19
  17. package/dataflow/environments/identifier.d.ts +18 -0
  18. package/dataflow/environments/query-fn-props.js +4 -3
  19. package/dataflow/environments/resolve-by-name.js +5 -3
  20. package/dataflow/eval/resolve/node-value.d.ts +1 -1
  21. package/dataflow/eval/resolve/node-value.js +2 -2
  22. package/dataflow/eval/resolve/resolve-argument.js +1 -1
  23. package/dataflow/extractor.js +20 -4
  24. package/dataflow/graph/df-helper.d.ts +42 -1
  25. package/dataflow/graph/df-helper.js +83 -0
  26. package/dataflow/info.d.ts +2 -0
  27. package/dataflow/info.js +4 -0
  28. package/dataflow/internal/linker.js +21 -5
  29. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +4 -0
  30. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +3 -0
  31. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +18 -2
  32. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +144 -30
  33. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  34. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -1
  35. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
  36. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -0
  37. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +8 -4
  38. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +43 -8
  39. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
  40. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +5 -4
  41. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +67 -3
  42. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -2
  43. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -3
  44. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  45. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -14
  46. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -7
  47. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +28 -10
  48. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +138 -89
  49. package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +1 -1
  50. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +87 -10
  51. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +8 -0
  52. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +23 -12
  53. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -1
  54. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +28 -10
  55. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -1
  56. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +7 -5
  57. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +2 -2
  58. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +18 -15
  59. package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
  60. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  61. package/dataflow/internal/process/functions/call/quoted.js +8 -7
  62. package/documentation/wiki-dataflow-graph.js +25 -1
  63. package/linter/rules/undefined-symbol.js +2 -2
  64. package/package.json +1 -1
  65. package/project/attached-packages.d.ts +11 -6
  66. package/project/attached-packages.js +37 -9
  67. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +5 -0
  68. package/project/plugins/file-plugins/files/flowr-namespace-file.js +13 -0
  69. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
  70. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +25 -2
  71. package/project/sigdb/build.js +7 -6
  72. package/project/sigdb/decode.d.ts +2 -0
  73. package/project/sigdb/decode.js +9 -3
  74. package/project/sigdb/schema.d.ts +8 -3
  75. package/queries/catalog/signature-query/signature-query-executor.js +15 -1
  76. package/queries/catalog/signature-query/signature-query-format.d.ts +3 -2
  77. package/r-bridge/data/data.d.ts +2 -2
  78. package/r-bridge/data/data.js +2 -2
  79. package/r-bridge/lang-4.x/ast/model/model.d.ts +2 -0
  80. package/r-bridge/lang-4.x/ast/model/model.js +6 -1
  81. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -1
  82. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +12 -1
  83. package/reconstruct/reconstruct.js +2 -5
  84. package/search/search-executor/search-enrichers.js +17 -2
  85. package/search/search-executor/search-generators.js +6 -2
  86. package/slicing/static/slice-call.d.ts +16 -0
  87. package/slicing/static/slice-call.js +42 -0
  88. package/slicing/static/static-slicer.js +6 -0
  89. package/util/flowr-version.d.ts +1 -1
  90. package/util/flowr-version.js +2 -2
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlowrNamespaceFile = void 0;
4
4
  exports.isExportedInNamespaceFormat = isExportedInNamespaceFormat;
5
+ exports.importOrigin = importOrigin;
5
6
  exports.isExportedInInfo = isExportedInInfo;
6
7
  exports.getExportedNames = getExportedNames;
7
8
  exports.getCallables = getCallables;
@@ -81,6 +82,18 @@ function isExportedInNamespaceFormat(fmt, name, pkg = 'current') {
81
82
  const nsInfo = pkg === 'current' ? fmt.current : fmt[pkg];
82
83
  return nsInfo ? isExportedInInfo(name, nsInfo) : false;
83
84
  }
85
+ /**
86
+ * The package an explicit `importFrom(pkg, name)` takes `name` from. A package exporting such a name defines nothing
87
+ * of it but re-exports that package's function (`dplyr::%>%` is `magrittr::%>%`), which stays its own export all the same.
88
+ */
89
+ function importOrigin(name, nsInfo) {
90
+ for (const [pkg, names] of nsInfo.importedPackages) {
91
+ if (names !== 'all' && names.includes(name)) {
92
+ return pkg;
93
+ }
94
+ }
95
+ return undefined;
96
+ }
84
97
  /** As {@link isExportedInNamespaceFormat}, but for one already picked {@link NamespaceInfo}. */
85
98
  function isExportedInInfo(name, nsInfo) {
86
99
  if (nsInfo.exportedSymbols.includes(name) || nsInfo.exportedFunctions.includes(name)
@@ -116,4 +116,4 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
116
116
  * The resolved {@link Package} (namespace and version) of a source's export view. What the configuration states
117
117
  * for the package (`stated`) is part of its interface, even where the source misses it.
118
118
  */
119
- export declare function packageFromExports(name: string, info: Pick<LibraryExports, 'exported' | 's4Classes' | 'version'>, stated?: Iterable<unknown>): Package;
119
+ export declare function packageFromExports(name: string, info: Pick<LibraryExports, 'exported' | 's4Classes' | 'version' | 'reexports'>, stated?: Iterable<unknown>): Package;
@@ -56,6 +56,7 @@ const r_version_1 = require("../../../util/r-version");
56
56
  const r_base_packages_1 = require("../../../util/r-base-packages");
57
57
  const defaultmap_1 = require("../../../util/collections/defaultmap");
58
58
  const arrays_1 = require("../../../util/collections/arrays");
59
+ const r_reexports_generated_1 = require("../../../data/r-reexports.generated");
59
60
  const secure_mode_1 = require("../../../util/secure-mode");
60
61
  /** the plugin's instance name (pass to `unregisterPlugins` to disable the default sigdb resolver) */
61
62
  exports.SigDbPluginName = 'flowr-analyzer-package-versions-sigdb-plugin';
@@ -493,7 +494,9 @@ exports.FlowrAnalyzerPackageVersionsSigDbPlugin = FlowrAnalyzerPackageVersionsSi
493
494
  * for the package (`stated`) is part of its interface, even where the source misses it.
494
495
  */
495
496
  function packageFromExports(name, info, stated) {
496
- const exported = stated === undefined ? info.exported.slice() : (0, arrays_1.uniqueArray)([...info.exported, ...[...stated].map(String)]);
497
+ /* a source that records no re-exports lacks them altogether, so R's own answer for the package stands in */
498
+ const reexports = info.reexports ?? knownReexports(name);
499
+ const exported = (0, arrays_1.uniqueArray)([...info.exported, ...reexports?.keys() ?? [], ...[...stated ?? []].map(String)]);
497
500
  const namespaceInfo = {
498
501
  exportedSymbols: exported,
499
502
  exportedFunctions: [],
@@ -502,7 +505,8 @@ function packageFromExports(name, info, stated) {
502
505
  exportedS4Classes: info.s4Classes.slice(),
503
506
  exportS3Generics: reconstructS3Generics(exported),
504
507
  exportedPatterns: [],
505
- importedPackages: new Map(),
508
+ /* a re-export is an `importFrom()` of the name the package exports */
509
+ importedPackages: reexportImports(reexports),
506
510
  loadsWithSideEffects: false,
507
511
  callable: exported
508
512
  };
@@ -510,4 +514,23 @@ function packageFromExports(name, info, stated) {
510
514
  carries no version rather than a made-up one */
511
515
  return new package_1.Package({ name, namespaceInfo, resolvedVersion: info.version || undefined });
512
516
  }
517
+ /** the re-exports R reports for `pkg`, see {@link RReexports} */
518
+ function knownReexports(pkg) {
519
+ const known = Object.hasOwn(r_reexports_generated_1.RReexports, pkg) ? r_reexports_generated_1.RReexports[pkg] : undefined;
520
+ return known === undefined ? undefined : new Map(Object.entries(known.reexports));
521
+ }
522
+ /** the `importFrom(origin, names)` directives behind a source's re-exports, grouped by origin */
523
+ function reexportImports(reexports) {
524
+ const imports = new Map();
525
+ for (const [fn, origin] of reexports ?? []) {
526
+ const names = imports.get(origin);
527
+ if (names === undefined) {
528
+ imports.set(origin, [fn]);
529
+ }
530
+ else {
531
+ names.push(fn);
532
+ }
533
+ }
534
+ return imports;
535
+ }
513
536
  //# sourceMappingURL=flowr-analyzer-package-versions-sigdb-plugin.js.map
@@ -127,7 +127,8 @@ function buildBlob(p, strings, tier, feats) {
127
127
  const fn = (f) => {
128
128
  const base = [strings.str(f.name), sig(f.params), cg(f.callees), f.props,
129
129
  feats.locations && f.file ? strings.str(f.file) : -1, feats.locations ? f.line ?? -1 : -1];
130
- const rec = f.topic && f.topic !== f.name ? [...base, strings.str(f.topic)] : base;
130
+ const topic = f.topic && f.topic !== f.name ? strings.str(f.topic) : -1;
131
+ const rec = f.reexportOf ? [...base, topic, strings.str(f.reexportOf)] : topic >= 0 ? [...base, topic] : base;
131
132
  return fns.intern(rec.join(','), rec);
132
133
  };
133
134
  const depList = (list) => {
@@ -388,9 +389,7 @@ function optimizeStringOrder(strings, blobs) {
388
389
  for (const f of blob.fns) {
389
390
  bump(f[0]);
390
391
  bump(f[4]);
391
- if (f[6] !== undefined) {
392
- bump(f[6]);
393
- }
392
+ f.slice(6).forEach(bump);
394
393
  }
395
394
  for (const list of blob.deps) {
396
395
  for (const d of list) {
@@ -458,8 +457,10 @@ function optimizeStringOrder(strings, blobs) {
458
457
  if (f[4] >= 0) {
459
458
  f[4] = remap[f[4]];
460
459
  }
461
- if (f[6] !== undefined && f[6] >= 0) {
462
- f[6] = remap[f[6]];
460
+ for (let i = 6; i < f.length; i++) {
461
+ if (f[i] >= 0) {
462
+ f[i] = remap[f[i]];
463
+ }
463
464
  }
464
465
  }
465
466
  for (const list of blob.deps) {
@@ -42,6 +42,8 @@ export interface DecodedFunction {
42
42
  readonly callees: readonly string[];
43
43
  /** the Rd help topic (man-page name) documenting this function, when it differs from {@link name} */
44
44
  readonly topic?: string;
45
+ /** the package this name is re-exported from, see {@link SigFunctionInfo.reexportOf} */
46
+ readonly reexportOf?: string;
45
47
  }
46
48
  /**
47
49
  * The transitive callees of `name`. Each local callee that is itself a function of `functions` (one package
@@ -75,7 +75,7 @@ function transitiveCallees(functions, name) {
75
75
  }
76
76
  /** decode one of a blob's function records against the global string dictionary */
77
77
  function decodeFunction(strings, blob, fnIdx) {
78
- const [nameIdx, sigIdx, cgIdx, bits, fileIdx, line, topicIdx] = blob.fns[fnIdx];
78
+ const [nameIdx, sigIdx, cgIdx, bits, fileIdx, line, topicIdx, reexportIdx] = blob.fns[fnIdx];
79
79
  const name = strings.at(nameIdx);
80
80
  const signature = (sigIdx >= 0 ? blob.sigs[sigIdx] : []).map(p => {
81
81
  const [n, props, def] = Array.isArray(p) ? [p[0], p[1], p.length === 3 ? p[2] : -1] : [p, 0, -1];
@@ -89,6 +89,7 @@ function decodeFunction(strings, blob, fnIdx) {
89
89
  return (0, objects_1.compactRecord)({
90
90
  name,
91
91
  topic: topicIdx !== undefined && topicIdx >= 0 ? strings.at(topicIdx) : undefined,
92
+ reexportOf: reexportIdx !== undefined ? strings.at(reexportIdx) : undefined,
92
93
  file: fileIdx >= 0 ? strings.at(fileIdx) : undefined,
93
94
  line,
94
95
  exported: isExportedEntry(bits, name),
@@ -169,8 +170,9 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
169
170
  const s3Classes = [];
170
171
  const s4Classes = [];
171
172
  const locations = new Map();
173
+ const reexports = new Map();
172
174
  for (const i of idxs) {
173
- const [nameIdx, , , bits, fileIdx, line] = blob.fns[i];
175
+ const [nameIdx, , , bits, fileIdx, line, , reexportIdx] = blob.fns[i];
174
176
  const name = strings.at(nameIdx);
175
177
  (isExportedEntry(bits, name) ? exported : internal).push(name);
176
178
  if (bits & 32 /* FnProp.Deprecated */) {
@@ -185,12 +187,16 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
185
187
  if (fileIdx >= 0) {
186
188
  locations.set(name, { file: strings.at(fileIdx), line });
187
189
  }
190
+ if (reexportIdx !== undefined) {
191
+ reexports.set(name, strings.at(reexportIdx));
192
+ }
188
193
  }
189
194
  const cran = !blob.noncran?.includes(ver);
190
195
  return {
191
196
  version: ver, exported, internal, deprecated, s3Classes, s4Classes, cran,
192
197
  cranUrl: cranBlobUrl(cranBase, pkg, ver, { latest, archived: archived === 1, cran }),
193
- ...(locations.size > 0 ? { locations } : {})
198
+ ...(locations.size > 0 ? { locations } : {}),
199
+ ...(reexports.size > 0 ? { reexports } : {})
194
200
  };
195
201
  }
196
202
  //# sourceMappingURL=decode.js.map
@@ -30,6 +30,8 @@ export interface LibraryExports {
30
30
  readonly cranUrl?: string;
31
31
  /** definition location per identifier, if the database carries them */
32
32
  readonly locations?: ReadonlyMap<string, SigDefinitionLocation>;
33
+ /** the package each re-exported name comes from (`importFrom(magrittr, "%>%")` plus `export("%>%")`), if the database carries it */
34
+ readonly reexports?: ReadonlyMap<string, string>;
33
35
  }
34
36
  export declare const SigDbMagic = "flowr-sigdb";
35
37
  export declare const SigDbSchema = 5;
@@ -92,10 +94,11 @@ export type SigParam = number | [nameIdx: number, props: number] | [nameIdx: num
92
94
  export type Sig = SigParam[];
93
95
  /**
94
96
  * One function record `[nameIdx, sigIdx, cgIdx, propBits, fileIdx, line]` (`sigIdx`/`cgIdx`/`fileIdx` are -1 when
95
- * absent), with an optional trailing `topicIdx` (the Rd help topic, present only when it differs from the name).
96
- * The trailing element is additive: readers that stop at `line` ignore it, so older bundles stay readable.
97
+ * absent), with an optional trailing `topicIdx` (the Rd help topic, -1 when it equals the name) and, after it, an
98
+ * optional `reexportIdx` (the package a re-export comes from).
99
+ * The trailing elements are additive: readers that stop at `line` ignore them, so older bundles stay readable.
97
100
  */
98
- export type SigFn = [nameIdx: number, sigIdx: number, cgIdx: number, propBits: number, fileIdx: number, line: number] | [nameIdx: number, sigIdx: number, cgIdx: number, propBits: number, fileIdx: number, line: number, topicIdx: number];
101
+ export type SigFn = [nameIdx: number, sigIdx: number, cgIdx: number, propBits: number, fileIdx: number, line: number] | [nameIdx: number, sigIdx: number, cgIdx: number, propBits: number, fileIdx: number, line: number, topicIdx: number] | [nameIdx: number, sigIdx: number, cgIdx: number, propBits: number, fileIdx: number, line: number, topicIdx: number, reexportIdx: number];
99
102
  /** the object system a class record belongs to, mirroring {@link ClassSystem} in a single on-disk byte */
100
103
  export declare const enum SigClassSystem {
101
104
  S4 = 0,
@@ -236,6 +239,8 @@ export interface SigFunctionInfo {
236
239
  readonly line?: number;
237
240
  /** the Rd help topic (man-page name) documenting this function, when it differs from {@link name} */
238
241
  readonly topic?: string;
242
+ /** the package this name is re-exported from: the package defines nothing of the name, it imports and exports it */
243
+ readonly reexportOf?: string;
239
244
  }
240
245
  /** one declared package dependency, e.g. `{ name: 'testthat', type: Suggests, constraint: '>= 2.1.0' }` */
241
246
  export interface SigDependencyInfo {
@@ -401,6 +401,20 @@ function signatureCallGraphUrl(src, pkg, version, root, maxNodes) {
401
401
  const subgraphs = [...byOwner].flatMap(([owner, decls]) => [` subgraph ${owner}`, ...decls, ' end']);
402
402
  return mermaid_1.Mermaid.codeToUrl(['flowchart LR', ...subgraphs, ...ungrouped, ...edges].join('\n'));
403
403
  }
404
+ /** what `library(pkg)` puts on the search path besides `pkg`: its `Depends` and a meta-package's core set, and theirs in turn */
405
+ function attachedClosure(src, pkg, version) {
406
+ const attached = new Set([pkg]);
407
+ const visit = (p, at) => {
408
+ const { depends, onAttach } = (0, attached_packages_1.attachedAlongside)(p, [src], at);
409
+ for (const next of [...depends, ...onAttach].filter(n => !attached.has(n))) {
410
+ attached.add(next);
411
+ visit(next, undefined);
412
+ }
413
+ };
414
+ visit(pkg, version);
415
+ attached.delete(pkg);
416
+ return [...attached];
417
+ }
404
418
  /** the full view of a package: version, kind, export breakdown, dependencies, and every function's view */
405
419
  function signaturePackageInfo(src, pkg, resolved) {
406
420
  const exports = src.lookup(pkg, resolved) ?? src.lookup(pkg);
@@ -414,7 +428,7 @@ function signaturePackageInfo(src, pkg, resolved) {
414
428
  const deps = (src.dependencies(pkg, resolved) ?? src.dependencies(pkg) ?? [])
415
429
  .map(d => (0, objects_1.compactRecord)({ type: schema_1.DepTypeNames[d.type], name: d.name, constraint: d.constraint }));
416
430
  const release = src.releaseDate(pkg, resolved);
417
- const attaches = (0, attached_packages_1.attachedAlongside)(pkg, [src], resolved);
431
+ const attaches = attachedClosure(src, pkg, resolved);
418
432
  return (0, objects_1.compactRecord)({
419
433
  name: pkg,
420
434
  version: exports.version,
@@ -161,8 +161,9 @@ export interface SignaturePackageView {
161
161
  readonly coreVersions?: readonly string[];
162
162
  readonly dependencies: readonly SignatureDependencyView[];
163
163
  /**
164
- * The packages that end up on the search path together with this one, so that {@link exportsTotal} is not
165
- * mistaken for everything `library(<name>)` brings into scope (see `attachedAlongside`).
164
+ * The packages that end up on the search path together with this one, its `Depends` and a meta-package's core set,
165
+ * and theirs in turn, so that {@link exportsTotal} is not mistaken for everything `library(<name>)` brings into
166
+ * scope. Only what the database states; the analysis itself answers with `Dataflow.library.attaches`.
166
167
  */
167
168
  readonly attaches?: readonly string[];
168
169
  readonly functions: readonly SignatureFunctionView[];
@@ -227,8 +227,8 @@ export declare const flowrCapabilities: {
227
227
  readonly name: "Dynamic Search Path";
228
228
  readonly id: "dynamic-search-path";
229
229
  readonly code: readonly ["search", "searchpaths"];
230
- readonly supported: "not";
231
- readonly description: "_Programmatically inspecting or mutating the search path with `search()`, `searchpaths()`, or detaching by position._ None of this is modelled, and `search()` reads as an unknown call.";
230
+ readonly supported: "partially";
231
+ readonly description: "_Programmatically inspecting or mutating the search path with `search()`, `searchpaths()`, or detaching by position._ `search()` and `searchpaths()` read every `library`, `attach`, and `detach` before them, and `detach`/`unloadNamespace` remove the entry they name, but `search()` itself is not computed as a value.";
232
232
  readonly example: string;
233
233
  readonly url: [{
234
234
  name: string;
@@ -217,8 +217,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
217
217
  name: 'Dynamic Search Path',
218
218
  id: 'dynamic-search-path',
219
219
  code: ['search', 'searchpaths'],
220
- supported: 'not',
221
- description: '_Programmatically inspecting or mutating the search path with `search()`, `searchpaths()`, or detaching by position._ None of this is modelled, and `search()` reads as an unknown call.',
220
+ supported: 'partially',
221
+ description: '_Programmatically inspecting or mutating the search path with `search()`, `searchpaths()`, or detaching by position._ `search()` and `searchpaths()` read every `library`, `attach`, and `detach` before them, and `detach`/`unloadNamespace` remove the entry they name, but `search()` itself is not computed as a value.',
222
222
  example: (0, doc_code_1.codeBlock)('r', 'library(stats)\nn <- search()\nprint(n[2])'),
223
223
  url: [RLang('Search path')]
224
224
  },
@@ -161,6 +161,8 @@ export declare const RLoopConstructs: {
161
161
  * A set of all types of loop constructs in the normalized AST, i.e. for, repeat and while loops.
162
162
  */
163
163
  readonly loopConstructTypes: ReadonlySet<RType>;
164
+ /** Whether `id` may run again in the same frame, as part of a loop not left through a function definition. */
165
+ readonly encloses: <OtherInfo>(this: void, id: NodeId, idMap: AstIdMap<OtherInfo & ParentInformation>) => boolean;
164
166
  };
165
167
  /**
166
168
  * As an extension to {@link RLoopConstructs}, this subtype of {@link RNode} includes
@@ -61,7 +61,12 @@ exports.RLoopConstructs = {
61
61
  /**
62
62
  * A set of all types of loop constructs in the normalized AST, i.e. for, repeat and while loops.
63
63
  */
64
- loopConstructTypes: new Set([type_1.RType.ForLoop, type_1.RType.RepeatLoop, type_1.RType.WhileLoop])
64
+ loopConstructTypes: new Set([type_1.RType.ForLoop, type_1.RType.RepeatLoop, type_1.RType.WhileLoop]),
65
+ /** Whether `id` may run again in the same frame, as part of a loop not left through a function definition. */
66
+ encloses(id, idMap) {
67
+ const enclosing = exports.RNode.findEnclosing(id, idMap, n => r_function_definition_1.RFunctionDefinition.is(n) || exports.RLoopConstructs.is(n));
68
+ return enclosing !== undefined && !r_function_definition_1.RFunctionDefinition.is(idMap.get(enclosing));
69
+ }
65
70
  };
66
71
  /**
67
72
  * Helper for working with {@link RConstructs} AST nodes.
@@ -1,5 +1,6 @@
1
- import type { AstIdMap } from './decorate';
1
+ import type { AstIdMap, ParentInformation } from './decorate';
2
2
  import type { DataflowGraph } from '../../../../../dataflow/graph/graph';
3
+ import { RNode } from '../model';
3
4
  import type { BuiltInProcName } from '../../../../../dataflow/environments/built-in-proc-name';
4
5
  /**
5
6
  * The type of the id assigned to each node. Branded to avoid problematic usages with other string or numeric types.
@@ -85,6 +86,10 @@ export declare const NodeId: {
85
86
  * @see {@link NodeId.recoverContent} - for what a call or a use stands for rather than how it is written
86
87
  */
87
88
  readonly recoverName: (this: void, id: NodeId, idMap?: AstIdMap) => string | undefined;
89
+ /** The id of the call the dataflow graph makes up for an anonymous function a call runs (`lapply(x, function(v) v)`, a `tryCatch` handler). */
90
+ readonly anonymousCall: (this: void, functionId: NodeId) => NodeId;
91
+ /** The node `id` belongs to; for a made-up {@link NodeId.anonymousCall} the anonymous function it calls. */
92
+ readonly nodeOf: <Info>(this: void, id: NodeId, idMap: AstIdMap<Info> | undefined) => RNode<Info & ParentInformation> | undefined;
88
93
  /**
89
94
  * The name the {@link RNode|node} the id belongs to binds or reads, without the backticks or quotes R lets it be
90
95
  * written in (`"x"` and `x` in backticks both name `x`), which is how the environments know it.
@@ -11,6 +11,8 @@ function startsNumeric(id) {
11
11
  const c = id.charCodeAt(0);
12
12
  return c >= 48 && c <= 57 /* 0-9 */ || c === 45 /* - */ || c === 43 /* + */ || c === 46;
13
13
  }
14
+ /** see {@link NodeId.anonymousCall} */
15
+ const AnonymousCallPrefix = 'anon-';
14
16
  /**
15
17
  * What a {@link NodeId} is: the identity of a node within one analysis, plus the built-in and `pkg::fn`
16
18
  * names encoded as one, and the ways to read a name back out of it.
@@ -116,7 +118,16 @@ exports.NodeId = {
116
118
  * @see {@link NodeId.recoverContent} - for what a call or a use stands for rather than how it is written
117
119
  */
118
120
  recoverName(id, idMap) {
119
- return idMap?.get(id)?.lexeme;
121
+ return exports.NodeId.nodeOf(id, idMap)?.lexeme;
122
+ },
123
+ /** The id of the call the dataflow graph makes up for an anonymous function a call runs (`lapply(x, function(v) v)`, a `tryCatch` handler). */
124
+ anonymousCall(functionId) {
125
+ return AnonymousCallPrefix + String(functionId);
126
+ },
127
+ /** The node `id` belongs to; for a made-up {@link NodeId.anonymousCall} the anonymous function it calls. */
128
+ nodeOf(id, idMap) {
129
+ const node = idMap?.get(id);
130
+ return node !== undefined || typeof id !== 'string' || !id.startsWith(AnonymousCallPrefix) ? node : idMap?.get(exports.NodeId.normalize(id.slice(AnonymousCallPrefix.length)));
120
131
  },
121
132
  /**
122
133
  * The name the {@link RNode|node} the id belongs to binds or reads, without the backticks or quotes R lets it be
@@ -402,11 +402,8 @@ function reconstructFunctionCall(call, functionName, args, configuration) {
402
402
  }
403
403
  if (!selected) {
404
404
  const f = args.filter(a => a !== r_function_call_1.EmptyArgument && a.length !== 0);
405
- if (f.length === 0) {
406
- return [];
407
- }
408
- else if (f.length === 1) {
409
- return f[0];
405
+ if (f.length <= 1 || (call.infixSpecial !== true && functionName.length === 0)) {
406
+ return f.flat();
410
407
  }
411
408
  }
412
409
  if (call.infixSpecial === true) {
@@ -13,6 +13,11 @@ const identify_link_to_last_call_relation_1 = require("../../queries/catalog/cal
13
13
  const identifier_1 = require("../../dataflow/environments/identifier");
14
14
  const df_helper_1 = require("../../dataflow/graph/df-helper");
15
15
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
16
+ /** The search element of the node `id` belongs to (see {@link NodeId.nodeOf}), `undefined` if there is none. */
17
+ function elementOf(id, idMap) {
18
+ const node = node_id_1.NodeId.nodeOf(id, idMap);
19
+ return node === undefined ? undefined : { node };
20
+ }
16
21
  /**
17
22
  * An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
18
23
  * See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
@@ -44,6 +49,13 @@ function collectAliveNodes(ast, reachable) {
44
49
  alive.add(node.info.id);
45
50
  }
46
51
  }
52
+ /* a node the analysis made up for a call (the variables `load` restores) is no code of its own, it runs with the call */
53
+ for (const [id, node] of ast.idMap) {
54
+ const parent = node.info.parent === undefined || !alive.has(node.info.parent) ? undefined : ast.idMap.get(node.info.parent);
55
+ if (parent !== undefined && !alive.has(id) && !model_1.RNode.directChildren(parent).includes(node)) {
56
+ alive.add(id);
57
+ }
58
+ }
47
59
  return alive;
48
60
  }
49
61
  /**
@@ -132,7 +144,7 @@ exports.Enrichments = {
132
144
  // user-code node, so surface it as a built-in identifier (see `onlyBuiltin` above)
133
145
  return qualifyIdentifier([o], node_id_1.NodeId.recoverName(o.id, n.idMap)) ?? String(o.id);
134
146
  }
135
- return { node: n.idMap.get(o.id) };
147
+ return elementOf(o.id, n.idMap);
136
148
  case 3 /* OriginType.BuiltInFunctionOrigin */: {
137
149
  /* an alias (`s <- system; s()`) calls the built-in it is linked to rather than its own name */
138
150
  const linked = node_id_1.NodeId.isBuiltIn(o.proc) ? node_id_1.NodeId.toPkgFn(o.proc)?.[1] ?? node_id_1.NodeId.fromBuiltIn(o.proc) : undefined;
@@ -177,7 +189,10 @@ exports.Enrichments = {
177
189
  type: 'link-to-last-call',
178
190
  });
179
191
  for (const lastCall of lastCalls) {
180
- content.linkedIds.push({ node: n.idMap.get(lastCall) });
192
+ const linked = elementOf(lastCall, n.idMap);
193
+ if (linked !== undefined) {
194
+ content.linkedIds.push(linked);
195
+ }
181
196
  }
182
197
  }
183
198
  }
@@ -4,6 +4,7 @@ exports.generators = exports.searchLogger = void 0;
4
4
  exports.getGenerator = getGenerator;
5
5
  const flowr_search_1 = require("../flowr-search");
6
6
  const parse_1 = require("../../slicing/criterion/parse");
7
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
7
8
  const assert_1 = require("../../util/assert");
8
9
  const range_1 = require("../../util/range");
9
10
  const query_1 = require("../../queries/query");
@@ -90,8 +91,11 @@ async function generateFromQuery(input, args) {
90
91
  }
91
92
  const nodes = new Set();
92
93
  const queryDef = query_1.SupportedQueries[query];
93
- for (const node of (queryDef.flattenInvolvedNodes?.(content, args.from, args.certainty) ?? [])) {
94
- nodes.add({ node: idMap.get(node) });
94
+ for (const id of (queryDef.flattenInvolvedNodes?.(content, args.from, args.certainty) ?? [])) {
95
+ const node = node_id_1.NodeId.nodeOf(id, idMap);
96
+ if (node !== undefined) {
97
+ nodes.add({ node });
98
+ }
95
99
  }
96
100
  nodesByQuery.set(query, nodes);
97
101
  }
@@ -8,6 +8,7 @@ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { DataflowInformation } from '../../dataflow/info';
9
9
  import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
10
10
  import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
11
+ import { FnSig } from '../../dataflow/environments/built-in-props';
11
12
  /**
12
13
  * Returns the function call targets (definitions) by the given caller
13
14
  */
@@ -33,3 +34,18 @@ export declare function sliceReachesFunctionInterface(fnDefId: NodeId, graph: Da
33
34
  export declare function includeCalleesOfDefinition(fnDefId: NodeId, graph: DataflowGraph, queue: VisitingQueue, baseEnvironment: REnvironmentInformation, baseEnvFingerprint: Fingerprint): NodeId[];
34
35
  /** Returns true if we found at least one return edge */
35
36
  export declare function handleReturns(from: NodeId, queue: VisitingQueue, currentEdges: ReadonlyOutgoingEdges, baseEnvFingerprint: Fingerprint, baseEnvironment: REnvironmentInformation): boolean;
37
+ /** What decides whether a call runs code elsewhere: the role of each argument, and whether it evaluates code (`eval`) at all. */
38
+ interface DeferringInfo {
39
+ readonly sig?: FnSig;
40
+ readonly evaluates: boolean;
41
+ }
42
+ /**
43
+ * The built-in call that decides when, where or whether the code at `id` runs: the closest call it is an argument
44
+ * of that quotes it or calls it (`on.exit(expr)`, `do.call("f", args)`, `delayedAssign(x, expr)`), up to the
45
+ * function it is defined in. Without that call, the code would run in the order of the caller. A call capturing
46
+ * its argument for another call to evaluate is left to the evaluation of captured code, as that one drops it
47
+ * where the captured code is run in place.
48
+ * @param sigs - the signatures of the calls met on the way, filled as they are asked for
49
+ */
50
+ export declare function deferringCall(id: NodeId, info: DataflowInformation, idMap: AstIdMap, sigs: Map<NodeId, DeferringInfo>): NodeId | undefined;
51
+ export {};
@@ -5,6 +5,7 @@ exports.sliceForCall = sliceForCall;
5
5
  exports.sliceReachesFunctionInterface = sliceReachesFunctionInterface;
6
6
  exports.includeCalleesOfDefinition = includeCalleesOfDefinition;
7
7
  exports.handleReturns = handleReturns;
8
+ exports.deferringCall = deferringCall;
8
9
  const assert_1 = require("../../util/assert");
9
10
  const fingerprint_1 = require("./fingerprint");
10
11
  const linker_1 = require("../../dataflow/internal/linker");
@@ -19,6 +20,11 @@ const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
19
20
  const vertex_1 = require("../../dataflow/graph/vertex");
20
21
  const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
21
22
  const df_helper_1 = require("../../dataflow/graph/df-helper");
23
+ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
24
+ const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
25
+ const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
26
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
27
+ const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
22
28
  const NoCallTargets = new Set();
23
29
  const linkedByGraph = new WeakMap();
24
30
  function linkedFunctionsOf(defs, graph) {
@@ -163,4 +169,40 @@ function handleReturns(from, queue, currentEdges, baseEnvFingerprint, baseEnviro
163
169
  }
164
170
  return true;
165
171
  }
172
+ /** What a call states of an argument it does not evaluate where and when it stands: quoted, or called as a function. */
173
+ const RunsElsewhere = built_in_props_1.ArgProp.Nse | built_in_props_1.ArgProp.Callee;
174
+ /** A promise the call does not force may run any number of times, or never, as with `replicate(n, expr)`. */
175
+ function runsElsewhere(prop) {
176
+ return (prop & RunsElsewhere) !== 0 || (prop & (built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced)) === built_in_props_1.ArgProp.Value;
177
+ }
178
+ /**
179
+ * The built-in call that decides when, where or whether the code at `id` runs: the closest call it is an argument
180
+ * of that quotes it or calls it (`on.exit(expr)`, `do.call("f", args)`, `delayedAssign(x, expr)`), up to the
181
+ * function it is defined in. Without that call, the code would run in the order of the caller. A call capturing
182
+ * its argument for another call to evaluate is left to the evaluation of captured code, as that one drops it
183
+ * where the captured code is run in place.
184
+ * @param sigs - the signatures of the calls met on the way, filled as they are asked for
185
+ */
186
+ function deferringCall(id, info, idMap, sigs) {
187
+ for (let child = idMap.get(id), parent = child && model_1.RNode.directParent(child, idMap); child !== undefined && parent !== undefined && !r_function_definition_1.RFunctionDefinition.is(parent); child = parent, parent = model_1.RNode.directParent(parent, idMap)) {
188
+ if (!r_argument_1.RArgument.is(child) || !r_function_call_1.RFunctionCall.is(parent)) {
189
+ continue;
190
+ }
191
+ const call = parent.info.id;
192
+ let known = sigs.get(call);
193
+ if (known === undefined) {
194
+ const props = (0, query_fn_props_1.callFnProps)(call, info);
195
+ known = { sig: props?.sig, evaluates: props?.tags?.includes(built_in_props_1.SemanticCallTag.Eval) === true };
196
+ sigs.set(call, known);
197
+ }
198
+ /* quoted code the dataflow evaluates in place needs neither the quote nor the evaluating call */
199
+ if (vertex_1.DfgVertex.hasOrigin(info.graph.getVertex(call), built_in_proc_name_1.BuiltInProcName.Quote)) {
200
+ return undefined;
201
+ }
202
+ if (known.evaluates || (known.sig !== undefined && runsElsewhere(built_in_props_1.FnSig.propAt(built_in_props_1.FnSig.layout(known.sig), parent.arguments.indexOf(child))))) {
203
+ return call;
204
+ }
205
+ }
206
+ return undefined;
207
+ }
166
208
  //# sourceMappingURL=slice-call.js.map
@@ -45,6 +45,7 @@ function staticSlice(options) {
45
45
  const basePrint = ctx.env.getCleanEnvFingerprint();
46
46
  const queue = new visiting_queue_1.VisitingQueue(options.threshold ?? 75, cache, graph, ctx.gas.scope(options.gas), [emptyEnv, basePrint]);
47
47
  const enclosingHandled = new Set();
48
+ const callSigs = new Map();
48
49
  /* the unknown side effects every slice keeps are seeds as well, so what they reach is not cut off as running too late */
49
50
  const effects = [...graph.unknownSideEffects].filter((id) => typeof id !== 'object');
50
51
  const missesSeeds = sliceGraph === undefined ? outsideSeedRun([...ids, ...effects], idMap, direction, graph) : undefined;
@@ -119,6 +120,11 @@ function staticSlice(options) {
119
120
  queue.add(cd.id, baseEnvironment, baseEnvFingerprint, false);
120
121
  }
121
122
  }
123
+ /* code a call quotes or calls runs where and when that call says, so the call stays with it */
124
+ const deferring = (0, slice_call_1.deferringCall)(id, info, idMap, callSigs);
125
+ if (deferring !== undefined) {
126
+ enqueue(deferring, baseEnvironment, baseEnvFingerprint);
127
+ }
122
128
  /* a call or a definition within a promise runs only when the promise is forced, within captured code only when it is evaluated */
123
129
  if (vertex_1.DfgVertex.isFunctionCall(currentVertex) || vertex_1.DfgVertex.isVariableDefinition(currentVertex)) {
124
130
  const dependencies = function_semantics_1.FunctionSemantics.promiseDependencies(id, graph);
@@ -3,7 +3,7 @@
3
3
  * @module
4
4
  */
5
5
  import { SemVer } from 'semver';
6
- export declare const versionDate = "2026-11-03T17:01:03Z";
6
+ export declare const versionDate = "2026-11-06T08:48:46Z";
7
7
  /**
8
8
  * Retrieves the current flowR version as a new {@link SemVer} object.
9
9
  */
@@ -8,9 +8,9 @@ exports.flowrVersion = flowrVersion;
8
8
  */
9
9
  const semver_1 = require("semver");
10
10
  // this is automatically replaced with the current version by release-it
11
- const version = '2.17.1';
11
+ const version = '2.17.3';
12
12
  // this is automatically replaced with the release date by release-it (scripts/bump-version.ts)
13
- exports.versionDate = '2026-11-03T17:01:03Z';
13
+ exports.versionDate = '2026-11-06T08:48:46Z';
14
14
  /**
15
15
  * Retrieves the current flowR version as a new {@link SemVer} object.
16
16
  */