@eagleoutice/flowr 2.15.0 → 2.15.2

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 (30) hide show
  1. package/README.md +14 -14
  2. package/abstract-interpretation/data-frame/dataframe-semantics.js +14 -5
  3. package/dataflow/environments/identifier.d.ts +2 -0
  4. package/dataflow/environments/identifier.js +8 -1
  5. package/dataflow/environments/query-fn-props.d.ts +9 -1
  6. package/dataflow/environments/query-fn-props.js +88 -10
  7. package/dataflow/eval/resolve/alias-tracking.js +4 -4
  8. package/dataflow/eval/resolve/resolve.js +11 -1
  9. package/dataflow/eval/values/general.d.ts +2 -0
  10. package/dataflow/eval/values/general.js +5 -0
  11. package/dataflow/eval/values/sets/set-constants.d.ts +5 -0
  12. package/dataflow/eval/values/sets/set-constants.js +9 -1
  13. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +2 -1
  14. package/linter/rules/problematic-inputs.js +1 -1
  15. package/linter/rules/undefined-symbol.js +3 -2
  16. package/package.json +1 -1
  17. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
  18. package/project/sigdb/build.js +38 -0
  19. package/project/sigdb/manifest.js +1 -1
  20. package/project/sigdb/reader.d.ts +18 -5
  21. package/project/sigdb/reader.js +121 -19
  22. package/queries/catalog/dice-query/dice-query-executor.js +3 -2
  23. package/queries/catalog/input-sources-query/simple-input-classifier.js +67 -0
  24. package/queries/catalog/slice-query-options.d.ts +10 -4
  25. package/queries/catalog/slice-query-options.js +27 -5
  26. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
  27. package/queries/catalog/static-slice-query/static-slice-query-executor.js +7 -4
  28. package/queries/query.d.ts +56 -2
  29. package/queries/query.js +66 -1
  30. package/util/version.js +2 -2
package/README.md CHANGED
@@ -47,7 +47,7 @@ It offers a wide variety of features, for example:
47
47
 
48
48
  ```shell
49
49
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
50
- flowR repl v2.14.4, R grammar v14 (tree-sitter engine)
50
+ flowR repl v2.15.0, R grammar v14 (tree-sitter engine)
51
51
  R> :query @linter "read.csv(\"/root/x.txt\")"
52
52
  ```
53
53
 
@@ -56,7 +56,7 @@ It offers a wide variety of features, for example:
56
56
 
57
57
 
58
58
  ```text
59
- Query: linter (6 ms)
59
+ Query: linter (7 ms)
60
60
  ╰ Deprecated Functions (deprecated-functions): no findings
61
61
  ╰ File Path Validity (file-path-validity): no findings
62
62
  ╰ Seeded Randomness (seeded-randomness): no findings
@@ -96,7 +96,7 @@ It offers a wide variety of features, for example:
96
96
 
97
97
  _Results (prettified and summarized):_
98
98
 
99
- Query: **linter** (10 ms)\
99
+ Query: **linter** (9 ms)\
100
100
     ╰ **Deprecated Functions** (deprecated-functions): _no findings_\
101
101
     ╰ **File Path Validity** (file-path-validity):\
102
102
         ╰ certain:\
@@ -106,7 +106,7 @@ It offers a wide variety of features, for example:
106
106
     ╰ **Absolute Paths** (absolute-file-paths):\
107
107
         ╰ certain:\
108
108
             ╰ Path `/root/x.txt` at 1.1-23\
109
-        ╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0\
109
+        ╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 0\
110
110
     ╰ **Unused Definitions** (unused-definitions): _no findings_\
111
111
     ╰ **Network Functions** (network-functions): _no findings_\
112
112
     ╰ **Dataframe Access Validation** (dataframe-access-validation): _no findings_\
@@ -124,7 +124,7 @@ It offers a wide variety of features, for example:
124
124
 
125
125
  <details> <summary style="color:gray">Show Detailed Results as Json</summary>
126
126
 
127
- The analysis required _9.9 ms_ (including parsing and normalization and the query) within the generation environment.
127
+ The analysis required _10.3 ms_ (including parsing and normalization and the query) within the generation environment.
128
128
 
129
129
  In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
130
130
  Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
@@ -141,7 +141,7 @@ It offers a wide variety of features, for example:
141
141
  ".meta": {
142
142
  "builtin": 0,
143
143
  "sigdb": 0,
144
- "searchTimeMs": 1,
144
+ "searchTimeMs": 0,
145
145
  "processTimeMs": 1
146
146
  }
147
147
  },
@@ -196,7 +196,7 @@ It offers a wide variety of features, for example:
196
196
  ".meta": {
197
197
  "totalConsidered": 1,
198
198
  "totalUnknown": 0,
199
- "searchTimeMs": 1,
199
+ "searchTimeMs": 0,
200
200
  "processTimeMs": 0
201
201
  }
202
202
  },
@@ -213,8 +213,8 @@ It offers a wide variety of features, for example:
213
213
  ".meta": {
214
214
  "totalCalls": 0,
215
215
  "totalFunctionDefinitions": 0,
216
- "searchTimeMs": 1,
217
- "processTimeMs": 0
216
+ "searchTimeMs": 0,
217
+ "processTimeMs": 1
218
218
  }
219
219
  },
220
220
  "dataframe-access-validation": {
@@ -319,7 +319,7 @@ It offers a wide variety of features, for example:
319
319
  }
320
320
  },
321
321
  ".meta": {
322
- "timing": 10
322
+ "timing": 9
323
323
  }
324
324
  },
325
325
  ".meta": {
@@ -389,7 +389,7 @@ It offers a wide variety of features, for example:
389
389
 
390
390
  ```shell
391
391
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
392
- flowR repl v2.14.4, R grammar v14 (tree-sitter engine)
392
+ flowR repl v2.15.0, R grammar v14 (tree-sitter engine)
393
393
  R> :query @static-slice (11@sum) file://test/testfiles/example.R
394
394
  ```
395
395
 
@@ -418,7 +418,7 @@ It offers a wide variety of features, for example:
418
418
  </details>
419
419
 
420
420
  * 🚀 **fast call-graph, data-, and control-flow graphs**\
421
- Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">109.6 ms</span></i> (as of Aug 23, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
421
+ Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">108.9 ms</span></i> (as of Aug 25, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
422
422
  _flowR_ can analyze the data- and control-flow of the average real-world R&nbsp;script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
423
423
  and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph#perspectives-cg).
424
424
  (&nbsp;[▶&nbsp;Explore in Browser](https://flowr-analysis.github.io/flowr/wiki/playground/#c=zDYSwRgTghhCeAUATADsWECUAoLBnAxlMAKYD6ALgPakC2UAHgAQA8AtIwGYCuAdvuSEo949DIyYB6RnXojsWaAHdGKlW0aIo5KADoO0GsXghEjALyMAjAC4AbABpGANyJdi5xvngBmRwA5HAHZHACZHAE5HABYMbHwSKB5VdQ4QYHJiCHglRxdgN0YAPkYQuISeABICImJTdWqSCmoZeHjiRIq8t3lcLho6OFJcbXJcFnZe-pgQXCM2xMdDRI8l4Qba2KxeLlnEJu1gNQm%2B7KhFTtdieUUIEAydfFwneEmB2CGR3EcAIleYWAeT2%2B2FQlHIrXKVUIJEQIMoIB4owh7UqJgwQA&p=13:1 "run this script in flowR's playground, no setup")&nbsp;)
@@ -456,7 +456,7 @@ It offers a wide variety of features, for example:
456
456
 
457
457
  ```shell
458
458
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
459
- flowR repl v2.14.4, R grammar v14 (tree-sitter engine)
459
+ flowR repl v2.15.0, R grammar v14 (tree-sitter engine)
460
460
  R> :dataflow* test/testfiles/example.R
461
461
  ```
462
462
 
@@ -765,7 +765,7 @@ It offers a wide variety of features, for example:
765
765
  ```
766
766
 
767
767
 
768
- (The analysis required _1.8 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
768
+ (The analysis required _3.0 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
769
769
 
770
770
 
771
771
 
@@ -603,7 +603,7 @@ function mapDataFrameCreate(args, params, ctx, info) {
603
603
  const argNames = args.map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
604
604
  const argLengths = args.map(arg => resolve_helper_1.Resolve.argument.vectorLength(arg, info));
605
605
  const allVectors = argLengths.every(assert_1.isNotUndefined);
606
- const rows = allVectors ? Math.max(...argLengths, 0) : undefined;
606
+ const rows = allVectors ? argLengths.reduce((max, length) => Math.max(max, length), 0) : undefined;
607
607
  let colnames = argNames;
608
608
  // over-approximate the column names if arguments are present but cannot be resolved to values
609
609
  if (!allVectors || typeof checkNames !== 'boolean' || typeof noDupNames !== 'boolean') {
@@ -1017,9 +1017,10 @@ function mapDataFrameMutate(args, params, ctx, info) {
1017
1017
  .filter(arg => !(0, arguments_1.isRNull)(arg))
1018
1018
  .map(arg => resolve_helper_1.Resolve.argument.toName(arg, info));
1019
1019
  // only column names that are not created by mutation are preconditions on the operand
1020
+ const mutatedColSet = new Set(mutatedCols);
1020
1021
  const accessedNames = mutateArgs
1021
1022
  .flatMap(arg => (0, arguments_1.getUnresolvedSymbolsInExpression)(arg, info.graph))
1022
- .filter(arg => !mutatedCols?.includes(arg));
1023
+ .filter(arg => !mutatedColSet.has(arg));
1023
1024
  deletedCols = (0, arguments_1.filterValidNames)(deletedCols, params.checkNames, params.noDupNames, undefined, true);
1024
1025
  mutatedCols = (0, arguments_1.filterValidNames)(mutatedCols, params.checkNames, params.noDupNames, undefined, true);
1025
1026
  if (accessedNames.length > 0) {
@@ -1229,6 +1230,14 @@ function mapDataFrameNamedColumnAccess(access, ctx, info) {
1229
1230
  columns: colname ? [colname] : undefined
1230
1231
  }];
1231
1232
  }
1233
+ /** the largest absolute index of a list, which can hold more entries than a spread could pass as arguments */
1234
+ function maxAbs(indices) {
1235
+ let max = -Infinity;
1236
+ for (const index of indices) {
1237
+ max = Math.max(max, Math.abs(index));
1238
+ }
1239
+ return max;
1240
+ }
1232
1241
  /**
1233
1242
  * Maps an index-based access of the rows and columns of a data frame, such as `df[1, ]` or `df[["id"]]`, to abstract data frame operations.
1234
1243
  */
@@ -1291,7 +1300,7 @@ function mapDataFrameIndexColRowAccess(access, ctx, info) {
1291
1300
  const colSubset = columns === undefined || columns.every(col => isColName(col) || col >= 0);
1292
1301
  const rowZero = rows?.length === 1 && rows[0] === 0;
1293
1302
  const colZero = columns?.length === 1 && columns[0] === 0;
1294
- const duplicateCols = columns?.some((col, index, list) => list.indexOf(col) !== index);
1303
+ const duplicateCols = columns !== undefined && new Set(columns).size !== columns.length;
1295
1304
  let operand = dataFrame;
1296
1305
  if (rowArg !== undefined && r_argument_1.RArgument.isNotEmpty(rowArg)) {
1297
1306
  if (rowSubset) {
@@ -1307,7 +1316,7 @@ function mapDataFrameIndexColRowAccess(access, ctx, info) {
1307
1316
  operand: operand?.info.id,
1308
1317
  rows: rowZero ? 0 : rows?.filter(index => index !== 0).length,
1309
1318
  /* R drops nothing for an index beyond the extent, so the semantics has to know how far they reach */
1310
- maxIndex: rows !== undefined ? Math.max(...rows.map(Math.abs)) : undefined
1319
+ maxIndex: rows !== undefined ? maxAbs(rows) : undefined
1311
1320
  });
1312
1321
  }
1313
1322
  operand = undefined;
@@ -1326,7 +1335,7 @@ function mapDataFrameIndexColRowAccess(access, ctx, info) {
1326
1335
  operation: 'removeCols',
1327
1336
  operand: operand?.info.id,
1328
1337
  colnames: columns?.map(toColName),
1329
- maxIndex: columns?.every(isIndex) ? Math.max(...columns.map(Math.abs)) : undefined
1338
+ maxIndex: columns?.every(isIndex) ? maxAbs(columns) : undefined
1330
1339
  });
1331
1340
  }
1332
1341
  // eslint-disable-next-line no-useless-assignment -- ends the chain
@@ -114,6 +114,8 @@ export declare const Identifier: {
114
114
  * If the first identifier is internal, it will match any target (internal or not).
115
115
  */
116
116
  readonly matches: (this: void, id: Identifier, target: Identifier, s3?: boolean) => boolean;
117
+ /** The text as a regex matches it literally: `[`, `$` and `.` name functions in R, they are not pattern syntax. */
118
+ readonly quote: (this: void, text: string) => string;
117
119
  /**
118
120
  * Helper to create a regular expression that matches against an array of {@link Identifier} values. If both the passed identifier and the matched identifier are namespaced, their namespaces are expected to match. If either is not namespaced, the namespace is ignored on both.
119
121
  */
@@ -180,12 +180,19 @@ exports.Identifier = {
180
180
  /* an omitted flag is the same as an explicit `false`, `pkg::fn` written either way is one identifier */
181
181
  return (idInternal ?? false) === (exports.Identifier.accessesInternal(target) ?? false);
182
182
  },
183
+ /** The text as a regex matches it literally: `[`, `$` and `.` name functions in R, they are not pattern syntax. */
184
+ quote(text) {
185
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
186
+ },
183
187
  /**
184
188
  * Helper to create a regular expression that matches against an array of {@link Identifier} values. If both the passed identifier and the matched identifier are namespaced, their namespaces are expected to match. If either is not namespaced, the namespace is ignored on both.
185
189
  */
186
190
  regex(...identifiers) {
187
191
  // if the passed identifier is not namespaced, we match against *any* namespace. if it is namespaced, we match against the correct namespace or no namespace
188
- return new RegExp(`^(${identifiers.map(i => `(${exports.Identifier.getNamespace(i) ?? '.+'}:::?)?${exports.Identifier.getName(i)}`).join('|')})$`);
192
+ return new RegExp(`^(${identifiers.map(i => {
193
+ const namespace = exports.Identifier.getNamespace(i);
194
+ return `(${namespace === undefined ? '.+' : exports.Identifier.quote(namespace)}:::?)?${exports.Identifier.quote(exports.Identifier.getName(i))}`;
195
+ }).join('|')})$`);
189
196
  },
190
197
  /** Special identifier for the `...` argument */
191
198
  dotdotdot() {
@@ -79,8 +79,12 @@ export interface BuiltInParam {
79
79
  * definition in the analyzed code shadows the built-in) use {@link queryFnProps} instead.
80
80
  */
81
81
  export declare class BuiltInIndex {
82
+ /** every built-in the index knows, one entry per namespace and name */
82
83
  readonly entries: readonly BuiltInEntry[];
84
+ /** the entry an unqualified name resolves to, the one R's default search path would find */
83
85
  private readonly byName;
86
+ /** namespace to name to entry, so a qualified name is two lookups and no string built to ask */
87
+ private readonly byNamespace;
84
88
  private readonly cache;
85
89
  private constructor();
86
90
  /** The index of flowR's own {@link DefaultBuiltinConfig}, computed on first use and shared from then on. */
@@ -109,7 +113,11 @@ export declare class BuiltInIndex {
109
113
  get folding(): readonly Identifier[];
110
114
  /** Every parameter whose argument carries at least one bit of `props`, like {@link ArgProp.Resource}. */
111
115
  params(props: ArgProps): BuiltInParam[];
112
- /** What the index states about `name`, ignoring any namespace (built-ins are registered by their bare name). */
116
+ /**
117
+ * What the index states about `name`. A qualified name answers for that package alone, so `stats::filter`
118
+ * does not report what `dplyr::filter` states; an unqualified one answers with what R's default search
119
+ * path would find, `base` first and the other {@link AttachedBasePackageSet|attached base packages} next.
120
+ */
113
121
  get(name: Identifier): BuiltInEntry | undefined;
114
122
  /** The {@link CallProp} bits of `name`, `undefined` when no built-in of that name states any. */
115
123
  propsOf(name: Identifier): CallProps | undefined;
@@ -14,6 +14,7 @@ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id"
14
14
  const resolve_helper_1 = require("./resolve-helper");
15
15
  const vertex_1 = require("../graph/vertex");
16
16
  const df_helper_1 = require("../graph/df-helper");
17
+ const r_base_packages_1 = require("../../util/r-base-packages");
17
18
  /**
18
19
  * What flowR states about the package export `definition` binds, `undefined` if it binds none or if flowR
19
20
  * states nothing about it. `library(pkg)` binds every export itself, and that binding hides the built-in layer.
@@ -93,13 +94,20 @@ function queryFnProps(name, { environment, builtIns, signatures, version }) {
93
94
  */
94
95
  function builtInLookup(ctx) {
95
96
  const environment = ctx?.env.makeCleanEnv();
97
+ /* keyed by namespace and name, as `stats::filter` and `dplyr::filter` are not the same function */
96
98
  const known = new Map();
97
99
  return name => {
100
+ const namespace = identifier_1.Identifier.getNamespace(name);
98
101
  const key = identifier_1.Identifier.getName(name);
99
- if (!known.has(key)) {
100
- known.set(key, environment === undefined ? BuiltInIndex.default().get(name) : queryFnProps(name, { environment }));
102
+ let bucket = known.get(namespace);
103
+ if (bucket === undefined) {
104
+ bucket = new Map();
105
+ known.set(namespace, bucket);
101
106
  }
102
- return known.get(key);
107
+ if (!bucket.has(key)) {
108
+ bucket.set(key, environment === undefined ? BuiltInIndex.default().get(name) : queryFnProps(name, { environment }));
109
+ }
110
+ return bucket.get(key);
103
111
  };
104
112
  }
105
113
  /** What flowR states about the call `id` makes, together with the name the call resolved to. */
@@ -150,7 +158,7 @@ function entryOfDefinition(definition) {
150
158
  }
151
159
  const info = definition.config;
152
160
  const folds = definition.type === 'function' && definition.evalHandler !== undefined;
153
- return builtInNames(definition).map(name => ({ name, props: info?.props, tags: info?.tags, sig: info?.sig, folds }));
161
+ return builtInNames(definition).map(name => ({ name, props: info?.props, tags: info?.tags, sig: info?.sig, folds, overrides: definition.overrides }));
154
162
  }
155
163
  function entriesOfMemory(builtIns) {
156
164
  const out = [];
@@ -172,6 +180,32 @@ function entriesOfMemory(builtIns) {
172
180
  return out;
173
181
  }
174
182
  let defaultIndex;
183
+ /**
184
+ * The one entry for a name several definitions state something about, the later definition winning wherever
185
+ * it states anything -- a definition that only adds a {@link FnSig} must not drop the props of the one before.
186
+ * A definition marked `overrides` replaces the earlier one outright, as that is what it says it does.
187
+ */
188
+ function mergedEntry(known, next) {
189
+ return {
190
+ name: next.name,
191
+ props: next.props ?? known.props,
192
+ tags: next.tags ?? known.tags,
193
+ sig: next.sig ?? known.sig,
194
+ folds: next.folds || known.folds
195
+ };
196
+ }
197
+ /** The entry alone, without what only the index build needs to know about it. */
198
+ function plainEntry({ name, props, tags, sig, folds }) {
199
+ return { name, props, tags, sig, folds };
200
+ }
201
+ /** How early R's default search path reaches a name, deciding which package an unqualified ask answers with. */
202
+ function searchPathRank(name) {
203
+ const namespace = identifier_1.Identifier.getNamespace(name);
204
+ if (namespace === undefined) {
205
+ return 0;
206
+ }
207
+ return namespace === "base" /* PkgName.Base */ ? 1 : r_base_packages_1.AttachedBasePackageSet.has(namespace) ? 2 : 3;
208
+ }
175
209
  /**
176
210
  * The one place to ask what flowR's built-ins are: _every pure function_, _every call that reads a file_,
177
211
  * _every parameter that names a resource_, _everything the value solver can fold_. Each answer is derived
@@ -184,13 +218,44 @@ let defaultIndex;
184
218
  * definition in the analyzed code shadows the built-in) use {@link queryFnProps} instead.
185
219
  */
186
220
  class BuiltInIndex {
221
+ /** every built-in the index knows, one entry per namespace and name */
187
222
  entries;
223
+ /** the entry an unqualified name resolves to, the one R's default search path would find */
188
224
  byName = new Map();
225
+ /** namespace to name to entry, so a qualified name is two lookups and no string built to ask */
226
+ byNamespace = new Map();
189
227
  cache = new Map();
190
- constructor(entries) {
191
- this.entries = entries;
192
- for (const e of entries) {
193
- this.byName.set(identifier_1.Identifier.getName(e.name), e);
228
+ constructor(definitions) {
229
+ const unqualified = new Map();
230
+ /* where each name was first seen, so the entries keep the order the definitions come in */
231
+ const order = [];
232
+ for (const e of definitions) {
233
+ const name = identifier_1.Identifier.getName(e.name);
234
+ const namespace = identifier_1.Identifier.getNamespace(e.name);
235
+ let bucket = unqualified;
236
+ if (namespace !== undefined) {
237
+ const inNamespace = this.byNamespace.get(namespace);
238
+ if (inNamespace === undefined) {
239
+ bucket = new Map();
240
+ this.byNamespace.set(namespace, bucket);
241
+ }
242
+ else {
243
+ bucket = inNamespace;
244
+ }
245
+ }
246
+ const known = bucket.get(name);
247
+ bucket.set(name, known === undefined || e.overrides ? plainEntry(e) : mergedEntry(known, e));
248
+ if (known === undefined) {
249
+ order.push([bucket, name]);
250
+ }
251
+ }
252
+ this.entries = order.map(([bucket, name]) => bucket.get(name));
253
+ for (const e of this.entries) {
254
+ const name = identifier_1.Identifier.getName(e.name);
255
+ const known = this.byName.get(name);
256
+ if (known === undefined || searchPathRank(e.name) < searchPathRank(known.name)) {
257
+ this.byName.set(name, e);
258
+ }
194
259
  }
195
260
  }
196
261
  /** The index of flowR's own {@link DefaultBuiltinConfig}, computed on first use and shared from then on. */
@@ -251,9 +316,22 @@ class BuiltInIndex {
251
316
  }
252
317
  return found;
253
318
  }
254
- /** What the index states about `name`, ignoring any namespace (built-ins are registered by their bare name). */
319
+ /**
320
+ * What the index states about `name`. A qualified name answers for that package alone, so `stats::filter`
321
+ * does not report what `dplyr::filter` states; an unqualified one answers with what R's default search
322
+ * path would find, `base` first and the other {@link AttachedBasePackageSet|attached base packages} next.
323
+ */
255
324
  get(name) {
256
- return this.byName.get(identifier_1.Identifier.getName(name));
325
+ const namespace = identifier_1.Identifier.getNamespace(name);
326
+ if (namespace === undefined) {
327
+ return this.byName.get(identifier_1.Identifier.getName(name));
328
+ }
329
+ const found = this.byNamespace.get(namespace)?.get(identifier_1.Identifier.getName(name));
330
+ if (found === undefined) {
331
+ return undefined;
332
+ }
333
+ /* the maps settled name and namespace, what is left is `::` asking for a name only `:::` states */
334
+ return identifier_1.Identifier.accessesInternal(found.name) !== true || identifier_1.Identifier.accessesInternal(name) === true ? found : undefined;
257
335
  }
258
336
  /** The {@link CallProp} bits of `name`, `undefined` when no built-in of that name states any. */
259
337
  propsOf(name) {
@@ -247,7 +247,7 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
247
247
  if (values.size === 0) {
248
248
  return r_value_1.Top;
249
249
  }
250
- return (0, set_constants_1.setFrom)(...values);
250
+ return (0, set_constants_1.setOf)([...values]);
251
251
  }
252
252
  /** given an unknown alias, we have to clear all values in the environments */
253
253
  (0, unknown_side_effect_1.onUnknownSideEffect)((_graph, env, _id, target) => {
@@ -345,7 +345,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
345
345
  const sequence = iteratedSequence(id, graph, idMap);
346
346
  if (sequence !== undefined) {
347
347
  const value = resolveIdToValue(sequence.info.id, { graph, idMap, ctx, blocked });
348
- return (0, r_value_1.isTop)(value) ? r_value_1.Top : (0, set_constants_1.setFrom)(...iteratedElements(value));
348
+ return (0, r_value_1.isTop)(value) ? r_value_1.Top : (0, set_constants_1.setOf)(iteratedElements(value));
349
349
  }
350
350
  const queue = new visiting_queue_1.VisitingQueue(10);
351
351
  const clean = ctx.env.makeCleanEnv();
@@ -442,7 +442,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
442
442
  values.add((0, general_1.valueFromRNodeConstant)(node));
443
443
  }
444
444
  }
445
- return values.size === 0 ? r_value_1.Top : (0, set_constants_1.setFrom)(...values);
445
+ return values.size === 0 ? r_value_1.Top : (0, set_constants_1.setOf)([...values]);
446
446
  }
447
447
  /**
448
448
  * Please use {@link resolveIdToValue}
@@ -466,6 +466,6 @@ function resolveToConstants(name, environment) {
466
466
  const d = def.value;
467
467
  values.add(d === undefined ? r_value_1.Top : (0, general_1.valueFromTsValue)(d));
468
468
  });
469
- return (0, set_constants_1.setFrom)(...values);
469
+ return (0, set_constants_1.setOf)([...values]);
470
470
  }
471
471
  //# sourceMappingURL=alias-tracking.js.map
@@ -108,14 +108,24 @@ function resolveAsSeq(args) {
108
108
  }
109
109
  return r_value_2.Top;
110
110
  }
111
+ /**
112
+ * How many elements of a sequence are worth naming one by one. `1:148066` is a loop bound rather than a set of
113
+ * indices anything asks about, and holding one object per element costs more than the precision is worth, so
114
+ * a longer sequence resolves to {@link Top} instead.
115
+ */
116
+ const MaxSequenceLength = 4096;
111
117
  /**
112
118
  * The elements `from:to` runs over, counting down whenever `to` is the smaller one, and stopping before it
113
- * would pass `to` (`1:3.5` ends at `3`). `undefined` for a bound that names no position to count from or to.
119
+ * would pass `to` (`1:3.5` ends at `3`). `undefined` for a bound that names no position to count from or to,
120
+ * and for a sequence longer than {@link MaxSequenceLength}.
114
121
  */
115
122
  function createNumberSequence(start, end) {
116
123
  if (!Number.isFinite(start.num) || !Number.isFinite(end.num)) {
117
124
  return undefined;
118
125
  }
126
+ else if (Math.floor(Math.abs(end.num - start.num)) + 1 > MaxSequenceLength) {
127
+ return undefined;
128
+ }
119
129
  const step = start.num <= end.num ? 1 : -1;
120
130
  const sequence = [];
121
131
  for (let i = start.num; step > 0 ? i <= end.num : i >= end.num; i += step) {
@@ -5,6 +5,8 @@ import type { RNumberValue } from '../../../r-bridge/lang-4.x/convert-values';
5
5
  * Takes n potentially lifted ops and returns `Top` or `Bottom` if any is `Top` or `Bottom`.
6
6
  */
7
7
  export declare function bottomTopGuard(...a: Lift<unknown>[]): typeof Top | typeof Bottom | undefined;
8
+ /** {@link bottomTopGuard} for a list that is already one, which a spread of many elements could not pass on */
9
+ export declare function bottomTopGuardOf(a: readonly Lift<unknown>[]): typeof Top | typeof Bottom | undefined;
8
10
  /**
9
11
  * Returns a value set, if a is not bottom or top, otherwise undefined.
10
12
  * Useful when working with values returned by {@link Resolve.toValue}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.bottomTopGuard = bottomTopGuard;
4
+ exports.bottomTopGuardOf = bottomTopGuardOf;
4
5
  exports.valueSetGuard = valueSetGuard;
5
6
  exports.soleValue = soleValue;
6
7
  exports.valueFromTsValue = valueFromTsValue;
@@ -20,6 +21,10 @@ const scalar_constants_1 = require("./scalar/scalar-constants");
20
21
  * Takes n potentially lifted ops and returns `Top` or `Bottom` if any is `Top` or `Bottom`.
21
22
  */
22
23
  function bottomTopGuard(...a) {
24
+ return bottomTopGuardOf(a);
25
+ }
26
+ /** {@link bottomTopGuard} for a list that is already one, which a spread of many elements could not pass on */
27
+ function bottomTopGuardOf(a) {
23
28
  if (a.some(r_value_1.isBottom)) {
24
29
  return r_value_1.Bottom;
25
30
  }
@@ -4,6 +4,11 @@ import { type Lift, type Value, type ValueSet, Top } from '../r-value';
4
4
  * @see {@link isSet} - to check whether a value is a set
5
5
  */
6
6
  export declare function setFrom<V extends Value[]>(...elements: V): Lift<ValueSet<Value[]>>;
7
+ /**
8
+ * {@link setFrom} for elements that are already a list, which a set of many of them could not be spread into.
9
+ * @see {@link isSet} - to check whether a value is a set
10
+ */
11
+ export declare function setOf(elements: readonly Value[]): Lift<ValueSet<Value[]>>;
7
12
  /**
8
13
  * Checks, whether the given value is a set.
9
14
  * @see {@link setFrom} - to create sets
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ValueSetBottom = exports.ValueSetTop = exports.ValueEmptySet = void 0;
4
4
  exports.setFrom = setFrom;
5
+ exports.setOf = setOf;
5
6
  exports.isSet = isSet;
6
7
  const general_1 = require("../general");
7
8
  const r_value_1 = require("../r-value");
@@ -15,10 +16,17 @@ function flattenSetElements(s) {
15
16
  * @see {@link isSet} - to check whether a value is a set
16
17
  */
17
18
  function setFrom(...elements) {
19
+ return setOf(elements);
20
+ }
21
+ /**
22
+ * {@link setFrom} for elements that are already a list, which a set of many of them could not be spread into.
23
+ * @see {@link isSet} - to check whether a value is a set
24
+ */
25
+ function setOf(elements) {
18
26
  const vals = elements.flatMap(e => {
19
27
  return e.type === 'set' ? flattenSetElements(e.elements) : e;
20
28
  });
21
- return (0, general_1.bottomTopGuard)(...vals) ?? {
29
+ return (0, general_1.bottomTopGuardOf)(vals) ?? {
22
30
  type: 'set',
23
31
  elements: vals
24
32
  };
@@ -93,8 +93,9 @@ function processStringTemplate(name, args, rootId, data, config) {
93
93
  continue;
94
94
  }
95
95
  const template = arg.value;
96
+ /* one generator for the whole template so its interpolations do not collide on the same ids */
97
+ const generator = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(`${name.lexeme}::${template.info.id}`, template.location);
96
98
  for (const code of interpolationsOf(template.content.str, open, close, config.markup)) {
97
- const generator = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(`${name.lexeme}::${template.info.id}`, template.location);
98
99
  const result = (0, built_in_source_1.sourceRequest)(rootId, (0, retriever_1.requestFromInput)(code), data, information, false, generator, true);
99
100
  /* the template stands where the call does, so what it leaves open resolves against the bindings here */
100
101
  (0, linker_1.linkInputs)([...result.in, ...result.unknownReferences], data.environment, [], result.graph, false);
@@ -13,7 +13,7 @@ const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
13
13
  const identifier_1 = require("../../dataflow/environments/identifier");
14
14
  const defaultConsider = [
15
15
  '^eval$',
16
- ...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.SemanticCallTag.Process).map(n => `^${identifier_1.Identifier.getName(n)}$`)
16
+ ...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.SemanticCallTag.Process).map(n => `^${identifier_1.Identifier.quote(identifier_1.Identifier.getName(n))}$`)
17
17
  ];
18
18
  const defaultPipeCommandFunctions = [
19
19
  { pattern: '^pdf$', argIdx: 0, argName: 'file' },
@@ -19,7 +19,7 @@ const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
19
19
  const LibraryLoadFunctions = new Set(['library', 'require', 'requireNamespace', 'loadNamespace', 'attachNamespace', 'load_all', 'use', 'p_load']);
20
20
  // standard packages attached by default; exports are in scope without library()
21
21
  /** test frameworks whose namespace a test file runs under implicitly (e.g. `tests/testthat/test-*.R` sees testthat's exports without a `library()`) */
22
- const ImplicitTestFrameworks = new Set(['testthat', 'tinytest', 'RUnit']);
22
+ const ImplicitTestFrameworks = ['testthat', 'tinytest', 'RUnit'];
23
23
  /** whether name is an export of a default-attached base package (needs no library()) */
24
24
  function isAttachedBaseName(name) {
25
25
  const owner = (0, r_base_packages_1.baseRExportOwner)(name);
@@ -51,7 +51,8 @@ exports.UNDEFINED_SYMBOL = {
51
51
  const isInstalledFile = (file) => file !== undefined && (installedFiles.has(file) || (0, undefined_symbol_util_1.isInstalledResourceFile)(file));
52
52
  // test files run under their framework's attached namespace, so a bare name a test framework exports is defined there
53
53
  const testFiles = new Set(ctx.files.getFilesByRole(flowr_file_1.FileRole.Test).map(f => f.path()));
54
- const isImplicitTestExport = (name, file) => file !== undefined && testFiles.has(file) && deps.packagesExporting(name).some(p => ImplicitTestFrameworks.has(p));
54
+ const testExports = new Set(testFiles.size === 0 ? [] : deps.signatureSources().flatMap(src => ImplicitTestFrameworks.flatMap(pkg => src.lookup(pkg)?.exported ?? [])));
55
+ const isImplicitTestExport = (name, file) => file !== undefined && testFiles.has(file) && testExports.has(name);
55
56
  // a library() we could not resolve could export any of these symbols; we still report but flag the
56
57
  // findings as low-confidence (`mayBeProvidedByUnresolvedLibrary`) so the severity can be lowered
57
58
  const unknownIds = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.15.0",
3
+ "version": "2.15.2",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -323,7 +323,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
323
323
  if (cached !== undefined) {
324
324
  return cached;
325
325
  }
326
- const sources = this.loadSources();
326
+ /* the historical bundle is not asked: a name is hinted so a `library()` can be added for it, and a package
327
+ only that bundle carries is one nothing can attach today */
328
+ const sources = this.loadSources().filter(s => describeLoadedDatabase(s).scope !== 'history');
327
329
  const seen = new Set();
328
330
  const owners = [];
329
331
  for (const src of sources) {
@@ -403,6 +403,25 @@ function optimizeStringOrder(strings, blobs) {
403
403
  for (const idx of Object.values(blob.sources ?? {})) {
404
404
  bump(idx);
405
405
  }
406
+ /* a class names itself, its superclasses, its slots and their types, all of them dictionary indices */
407
+ for (const c of blob.classes ?? []) {
408
+ bump(c[0]);
409
+ for (const superIdx of c[3]) {
410
+ bump(superIdx);
411
+ }
412
+ for (const slot of c[4]) {
413
+ if (typeof slot === 'number') {
414
+ bump(slot);
415
+ }
416
+ else {
417
+ bump(slot[0]);
418
+ bump(slot[1]);
419
+ }
420
+ }
421
+ if (c.length === 6) {
422
+ bump(c[5]);
423
+ }
424
+ }
406
425
  }
407
426
  const order = Array.from({ length: n }, (_, i) => i).sort((a, b) => counts[b] - counts[a] || a - b);
408
427
  const remap = new Int32Array(n);
@@ -454,6 +473,25 @@ function optimizeStringOrder(strings, blobs) {
454
473
  for (const [version, idx] of Object.entries(blob.sources ?? {})) {
455
474
  blob.sources[version] = remap[idx];
456
475
  }
476
+ for (const c of blob.classes ?? []) {
477
+ c[0] = remap[c[0]];
478
+ for (let i = 0; i < c[3].length; i++) {
479
+ c[3][i] = remap[c[3][i]];
480
+ }
481
+ for (let i = 0; i < c[4].length; i++) {
482
+ const slot = c[4][i];
483
+ if (typeof slot === 'number') {
484
+ c[4][i] = remap[slot];
485
+ }
486
+ else {
487
+ slot[0] = remap[slot[0]];
488
+ slot[1] = remap[slot[1]];
489
+ }
490
+ }
491
+ if (c.length === 6) {
492
+ c[5] = remap[c[5]];
493
+ }
494
+ }
457
495
  }
458
496
  return order.map(oldI => strings[oldI]);
459
497
  }
@@ -239,7 +239,7 @@ function defaultSigDbPaths(searchRoots) {
239
239
  // a standalone bundle is a `.sigs.ndjson` that is not a shard of a discovered manifest (`<manifest>.<shard>...`)
240
240
  const prefixes = [...manifests.keys()].map(k => k.replace(/\.manifest\.json$/, ''));
241
241
  const isShard = (name) => {
242
- const base = name.replace(new RegExp(`${schema_1.SigDbExt.replace('.', '\\.')}$`), '');
242
+ const base = name.replace(new RegExp(`${schema_1.SigDbExt.replace(/\./g, '\\.')}$`), '');
243
243
  return prefixes.some(p => base === p || base.startsWith(p + '.'));
244
244
  };
245
245
  const scopeRank = (name) => {