@eagleoutice/flowr 2.16.4 → 2.16.5

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 (64) hide show
  1. package/cli/repl/core.js +13 -2
  2. package/cli/repl/parser/slice-query-parser.d.ts +21 -5
  3. package/cli/repl/parser/slice-query-parser.js +33 -13
  4. package/core/steps/all/static-slicing/10-reconstruct.d.ts +2 -2
  5. package/dataflow/environments/built-in.d.ts +2 -0
  6. package/dataflow/environments/built-in.js +10 -2
  7. package/dataflow/environments/data-masking-functions.js +2 -1
  8. package/dataflow/environments/default-builtin-config.d.ts +31 -5
  9. package/dataflow/environments/default-builtin-config.js +12 -15
  10. package/dataflow/eval/resolve/alias-tracking.js +5 -2
  11. package/dataflow/eval/resolve/node-value.js +1 -1
  12. package/dataflow/eval/resolve/resolve-argument.js +2 -0
  13. package/dataflow/eval/resolve/resolve-strings.d.ts +10 -0
  14. package/dataflow/eval/resolve/resolve-strings.js +79 -12
  15. package/dataflow/extractor.js +11 -4
  16. package/dataflow/graph/applied-arguments.d.ts +5 -0
  17. package/dataflow/graph/applied-arguments.js +17 -0
  18. package/dataflow/graph/df-helper.js +2 -2
  19. package/dataflow/graph/graph.d.ts +5 -0
  20. package/dataflow/graph/graph.js +5 -0
  21. package/dataflow/info.js +8 -1
  22. package/dataflow/internal/linker.js +35 -13
  23. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +9 -1
  24. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +32 -12
  25. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -1
  26. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +7 -4
  27. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +11 -1
  28. package/dataflow/internal/process/functions/call/named-call-handling.js +4 -2
  29. package/dataflow/internal/process/functions/call/quoted.js +3 -3
  30. package/dataflow/internal/program-order.js +7 -1
  31. package/dataflow/processor.d.ts +2 -0
  32. package/documentation/doc-util/doc-types.js +4 -0
  33. package/linter/linter-executor.js +7 -0
  34. package/linter/rules/problematic-inputs.js +2 -2
  35. package/linter/rules/stop-with-call-arg.js +1 -1
  36. package/linter/rules/undefined-symbol.js +26 -3
  37. package/linter/rules/unused-definition.js +20 -1
  38. package/package.json +1 -1
  39. package/project/dependency-version-space.js +4 -6
  40. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
  41. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +9 -8
  42. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -0
  43. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +5 -0
  44. package/queries/catalog/dependencies-query/implicit-echo.js +26 -29
  45. package/queries/catalog/dependencies-query/plot-objects.js +6 -2
  46. package/queries/catalog/dice-query/dice-query-format.d.ts +1 -1
  47. package/queries/catalog/dice-query/dice-query-format.js +1 -1
  48. package/queries/catalog/slice-query-options.d.ts +3 -3
  49. package/queries/catalog/slice-query-options.js +1 -1
  50. package/queries/catalog/static-slice-query/static-slice-query-executor.js +12 -1
  51. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +7 -1
  52. package/queries/catalog/static-slice-query/static-slice-query-format.js +4 -2
  53. package/queries/query.d.ts +2 -2
  54. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -56
  55. package/reconstruct/inline/source-inline-map.d.ts +1 -1
  56. package/reconstruct/inline/source-inline-map.js +5 -3
  57. package/reconstruct/reconstruct.d.ts +8 -1
  58. package/reconstruct/reconstruct.js +12 -3
  59. package/slicing/static/removal-slice.d.ts +19 -0
  60. package/slicing/static/removal-slice.js +165 -0
  61. package/slicing/static/static-slicer.js +10 -5
  62. package/util/text/playground-link.d.ts +24 -1
  63. package/util/text/playground-link.js +16 -1
  64. package/util/version.js +2 -2
package/cli/repl/core.js CHANGED
@@ -81,6 +81,11 @@ function replCompleterKeywords() {
81
81
  return _replCompleterKeywords;
82
82
  }
83
83
  const defaultHistoryFile = path_1.default.join(os_1.default.tmpdir(), '.flowrhistory');
84
+ /** Lines like `[REPL Stats] ...` are printed by the repl itself, so they only reach the prompt when output is pasted back in, maybe with the prompt. */
85
+ function isReplStatsLine(line) {
86
+ const text = line.trimStart();
87
+ return (text.startsWith(prompt_1.rawPrompt) ? text.slice(prompt_1.rawPrompt.length).trimStart() : text).startsWith('[REPL Stats]');
88
+ }
84
89
  /** Labels a completion with what it does, see {@link CommandCompletions#labels|labels}. */
85
90
  function describeCompletion(insert, describe) {
86
91
  return `${insert} ${ansi_1.ansiFormatter.format(describe, { style: 2 /* FontStyles.Faint */ })}`;
@@ -390,7 +395,7 @@ async function replProcessAnswer(analyzer, output, expr, allowRSessionAccess, re
390
395
  */
391
396
  async function repl({ analyzer, historyFile = defaultHistoryFile, rl = readline.createInterface(makeDefaultReplReadline(analyzer.flowrConfig, historyFile)), output = repl_main_1.standardReplOutput, allowRSessionAccess = false }) {
392
397
  if (historyFile) {
393
- rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.join('\n'), { encoding: 'utf-8' }));
398
+ rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.filter(l => !isReplStatsLine(l)).join('\n'), { encoding: 'utf-8' }));
394
399
  }
395
400
  const ghostHint = (0, ghost_hint_1.installGhostHint)(rl, analyzer.flowrConfig, {
396
401
  suggest: line => completionSuggestion(line, analyzer.flowrConfig)
@@ -429,6 +434,12 @@ async function repl({ analyzer, historyFile = defaultHistoryFile, rl = readline.
429
434
  rl.question(activeWatcher !== undefined ? '' : (0, prompt_1.prompt)(), answer => {
430
435
  ghostHint.clear();
431
436
  sigintCount = 0;
437
+ if (isReplStatsLine(answer)) {
438
+ // copied REPL output, not input: keep it out of the history and do not run it
439
+ rl.history?.shift();
440
+ resolve();
441
+ return;
442
+ }
432
443
  rl.pause();
433
444
  replProcessAnswer(analyzer, output, answer, allowRSessionAccess).then(() => {
434
445
  rl.resume();
@@ -449,7 +460,7 @@ function loadReplHistory(historyFile) {
449
460
  if (!fs_1.default.existsSync(historyFile)) {
450
461
  return undefined;
451
462
  }
452
- return fs_1.default.readFileSync(historyFile, { encoding: 'utf-8' }).split('\n');
463
+ return fs_1.default.readFileSync(historyFile, { encoding: 'utf-8' }).split('\n').filter(l => !isReplStatsLine(l));
453
464
  }
454
465
  catch (e) {
455
466
  log_1.log.error(`Failed to load repl history from ${historyFile}: ${e?.message}`);
@@ -9,11 +9,20 @@ export interface SliceFlag {
9
9
  readonly flag: string;
10
10
  /** what the flag does, kept to a few words as it is offered as a completion */
11
11
  readonly describe: string;
12
- /** the flag this one only makes sense with, if any */
13
- readonly requires?: string;
12
+ /** the flags this one only makes sense with one of, if any */
13
+ readonly requires?: readonly string[];
14
14
  /** the flags this one must not be combined with */
15
15
  readonly conflicts?: readonly string[];
16
16
  }
17
+ /** the letter of every flag a criteria argument may end with, the one place they are spelled out */
18
+ export declare const SliceFlagLetter: {
19
+ readonly Forward: "f";
20
+ readonly Removal: "r";
21
+ readonly InlineSources: "i";
22
+ readonly IncludeCallees: "c";
23
+ readonly InlineFull: "I";
24
+ readonly Banners: "B";
25
+ };
17
26
  /** the flags every slicing query understands, see {@link sliceQueryOptionsParser} */
18
27
  export declare const SharedSliceFlags: readonly [{
19
28
  readonly flag: "i";
@@ -29,12 +38,17 @@ export declare const SharedSliceFlags: readonly [{
29
38
  }, {
30
39
  readonly flag: "B";
31
40
  readonly describe: "banners";
32
- readonly requires: "I";
41
+ readonly requires: readonly ["i", "I"];
33
42
  }];
34
43
  /** the flags of the `static-slice` query: a dice fixes both directions, so only it can be told to slice forward */
35
44
  export declare const StaticSliceFlags: readonly [{
36
45
  readonly flag: "f";
37
46
  readonly describe: "slice forward";
47
+ readonly conflicts: readonly ["r"];
48
+ }, {
49
+ readonly flag: "r";
50
+ readonly describe: "removal slice";
51
+ readonly conflicts: readonly ["f"];
38
52
  }, {
39
53
  readonly flag: "i";
40
54
  readonly describe: "inline sources";
@@ -49,18 +63,20 @@ export declare const StaticSliceFlags: readonly [{
49
63
  }, {
50
64
  readonly flag: "B";
51
65
  readonly describe: "banners";
52
- readonly requires: "I";
66
+ readonly requires: readonly ["i", "I"];
53
67
  }];
54
68
  /**
55
69
  * Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order).
56
70
  */
57
71
  export declare function sliceDirectionParser(argument: string): SliceDirection;
72
+ /** Whether the flag suffix of `argument` asks for the removal slice (`r`) rather than the slice. */
73
+ export declare function sliceRemovalParser(argument: string): boolean;
58
74
  /**
59
75
  * The {@link SliceQueryOptions} the flag suffix of `argument` requests, see {@link SharedSliceFlags}.
60
76
  * An absent flag is left out entirely, so the default of the query applies.
61
77
  */
62
78
  export declare function sliceQueryOptionsParser(argument: string): SliceQueryOptions;
63
- /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs I)` */
79
+ /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs i or I)` */
64
80
  export declare function describeSliceFlags(flags: readonly SliceFlag[]): string;
65
81
  /**
66
82
  * Warns about the flags of `argument` that `flags` does not know (a `f` on a dice, a typo, ...) or that
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StaticSliceFlags = exports.SharedSliceFlags = void 0;
3
+ exports.StaticSliceFlags = exports.SharedSliceFlags = exports.SliceFlagLetter = void 0;
4
4
  exports.sliceDirectionParser = sliceDirectionParser;
5
+ exports.sliceRemovalParser = sliceRemovalParser;
5
6
  exports.sliceQueryOptionsParser = sliceQueryOptionsParser;
6
7
  exports.describeSliceFlags = describeSliceFlags;
7
8
  exports.warnAboutSliceFlags = warnAboutSliceFlags;
@@ -39,20 +40,38 @@ function splitCriteriaArgument(argument) {
39
40
  function sliceFlagSuffix(argument) {
40
41
  return splitCriteriaArgument(argument)?.flags ?? '';
41
42
  }
43
+ /** the letter of every flag a criteria argument may end with, the one place they are spelled out */
44
+ exports.SliceFlagLetter = {
45
+ Forward: 'f',
46
+ Removal: 'r',
47
+ InlineSources: 'i',
48
+ IncludeCallees: 'c',
49
+ InlineFull: 'I',
50
+ Banners: 'B'
51
+ };
52
+ const { Forward, Removal, InlineSources, IncludeCallees, InlineFull, Banners } = exports.SliceFlagLetter;
42
53
  /** the flags every slicing query understands, see {@link sliceQueryOptionsParser} */
43
54
  exports.SharedSliceFlags = [
44
- { flag: 'i', describe: 'inline sources', conflicts: ['I'] },
45
- { flag: 'c', describe: 'include callees' },
46
- { flag: 'I', describe: 'inline all files', conflicts: ['i'] },
47
- { flag: 'B', describe: 'banners', requires: 'I' }
55
+ { flag: InlineSources, describe: 'inline sources', conflicts: [InlineFull] },
56
+ { flag: IncludeCallees, describe: 'include callees' },
57
+ { flag: InlineFull, describe: 'inline all files', conflicts: [InlineSources] },
58
+ { flag: Banners, describe: 'banners', requires: [InlineSources, InlineFull] }
48
59
  ];
49
60
  /** the flags of the `static-slice` query: a dice fixes both directions, so only it can be told to slice forward */
50
- exports.StaticSliceFlags = [{ flag: 'f', describe: 'slice forward' }, ...exports.SharedSliceFlags];
61
+ exports.StaticSliceFlags = [
62
+ { flag: Forward, describe: 'slice forward', conflicts: [Removal] },
63
+ { flag: Removal, describe: 'removal slice', conflicts: [Forward] },
64
+ ...exports.SharedSliceFlags
65
+ ];
51
66
  /**
52
67
  * Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order).
53
68
  */
54
69
  function sliceDirectionParser(argument) {
55
- return sliceFlagSuffix(argument).includes('f') ? slice_direction_1.SliceDirection.Forward : slice_direction_1.SliceDirection.Backward;
70
+ return sliceFlagSuffix(argument).includes(Forward) ? slice_direction_1.SliceDirection.Forward : slice_direction_1.SliceDirection.Backward;
71
+ }
72
+ /** Whether the flag suffix of `argument` asks for the removal slice (`r`) rather than the slice. */
73
+ function sliceRemovalParser(argument) {
74
+ return sliceFlagSuffix(argument).includes(Removal);
56
75
  }
57
76
  /**
58
77
  * The {@link SliceQueryOptions} the flag suffix of `argument` requests, see {@link SharedSliceFlags}.
@@ -60,15 +79,16 @@ function sliceDirectionParser(argument) {
60
79
  */
61
80
  function sliceQueryOptionsParser(argument) {
62
81
  const flags = sliceFlagSuffix(argument);
82
+ const inlining = flags.includes(Banners) ? 'banner' : true;
63
83
  return {
64
- ...(flags.includes('i') ? { inlineSources: true } : {}),
65
- ...(flags.includes('I') ? { inlineFull: flags.includes('B') ? 'banner' : true } : {}),
66
- ...(flags.includes('c') ? { includeCallees: true } : {})
84
+ ...(flags.includes(InlineSources) ? { inlineSources: inlining } : {}),
85
+ ...(flags.includes(InlineFull) ? { inlineFull: inlining } : {}),
86
+ ...(flags.includes(IncludeCallees) ? { includeCallees: true } : {})
67
87
  };
68
88
  }
69
- /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs I)` */
89
+ /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs i or I)` */
70
90
  function describeSliceFlags(flags) {
71
- return flags.map(f => `${f.flag} (${f.describe}${f.requires ? `, needs ${f.requires}` : ''})`).join(', ');
91
+ return flags.map(f => `${f.flag} (${f.describe}${f.requires ? `, needs ${f.requires.join(' or ')}` : ''})`).join(', ');
72
92
  }
73
93
  function warn(output, message) {
74
94
  output.stderr(output.formatter.format(message, { color: 3 /* Colors.Yellow */, effect: ansi_1.ColorEffect.Foreground }));
@@ -126,7 +146,7 @@ function sliceFlagCompletions(arg, flags) {
126
146
  }
127
147
  const has = (flag) => split.flags.includes(flag);
128
148
  const offered = flags.filter(f => !has(f.flag)
129
- && (f.requires === undefined || has(f.requires))
149
+ && (f.requires === undefined || f.requires.some(has))
130
150
  && !f.conflicts?.some(has));
131
151
  return {
132
152
  completions: [...offered.map(f => arg + f.flag), arg + ' '],
@@ -1,7 +1,7 @@
1
1
  import { internalPrinter } from '../../../print/print';
2
2
  import { PipelineStepStage } from '../../pipeline-step';
3
3
  import type { SliceResult } from '../../../../slicing/static/slicer-types';
4
- import { type InlineFull } from '../../../../reconstruct/reconstruct';
4
+ import { type InlineFull, type InlineSources } from '../../../../reconstruct/reconstruct';
5
5
  import type { NormalizedAst } from '../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
6
  import type { AutoSelectPredicate } from '../../../../reconstruct/auto-select/auto-select-defaults';
7
7
  import type { DataflowInformation } from '../../../../dataflow/info';
@@ -19,7 +19,7 @@ export interface ReconstructRequiredInput {
19
19
  * Inline resolvable `source()` calls into the reconstruction so the result is a single self-contained R text.
20
20
  * Cyclic and unresolvable `source()` calls are kept verbatim and reported via `reconstruct.inlineWarnings`.
21
21
  */
22
- inlineSources?: boolean;
22
+ inlineSources?: InlineSources;
23
23
  /**
24
24
  * Inline *every* file into the reconstruction, in flowR's loading order (which respects implicit sources).
25
25
  * Overrides {@link inlineSources} and {@link reconstructFiles}.
@@ -69,6 +69,8 @@ export interface BuiltInIdentifierDefinition extends IdentifierReference {
69
69
  };
70
70
  /** folds a call to this function to a constant, see {@link BuiltInEvalHandlerMapper} */
71
71
  evalHandler?: BuiltInEvalHandler;
72
+ /** the processor's name, for a call made on our behalf (`do.call(new.env, list())`) that does not run it */
73
+ processorName?: BuiltInProcName;
72
74
  }
73
75
  export interface BuiltInIdentifierConstant<T = unknown> extends IdentifierReference {
74
76
  type: ReferenceType.BuiltInConstant;
@@ -200,12 +200,19 @@ function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsPro
200
200
  (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, masked, { kind: known_call_handling_1.NseKind.DataMasked, first });
201
201
  return ambient === undefined ? information : (0, built_in_ambient_state_1.applyAmbientStateAccess)(information, args, rootId, data, ambient);
202
202
  }
203
- /** A call that reads or writes the files its arguments name accesses the {@link AmbientStateName.files|files on disk} as well. */
203
+ /**
204
+ * A call that reads or writes the files its arguments name accesses the {@link AmbientStateName.files|files on disk} as well.
205
+ * Closing a device writes the file its opening already wrote, and only a device's file name may number its pages (`plot%03d.png`).
206
+ */
204
207
  function withFileAccess(config) {
205
208
  const { tags, ambient, sig } = (config ?? {});
206
209
  const type = !tags?.includes(built_in_props_1.SemanticCallTag.File) ? undefined : tags.includes(built_in_props_1.SemanticCallTag.Writes) ? "write-files" /* AmbientStateAccessType.WriteFiles */ : tags.includes(built_in_props_1.SemanticCallTag.Reads) ? "read-files" /* AmbientStateAccessType.ReadFiles */ : undefined;
207
210
  const stated = [ambient ?? []].flat();
208
- return type === undefined || stated.some(a => a.type === type) ? config : { ...config, ambient: [...stated, { type, sig: tags?.includes(built_in_props_1.SemanticCallTag.Glob) ? undefined : sig }] };
211
+ if (type === undefined || stated.some(a => a.type === type || a.type === "close-device" /* AmbientStateAccessType.CloseDevice */)) {
212
+ return config;
213
+ }
214
+ const numbered = stated.some(a => a.type === "open-device" /* AmbientStateAccessType.OpenDevice */);
215
+ return { ...config, ambient: [...stated, { type, sig: tags?.includes(built_in_props_1.SemanticCallTag.Glob) ? undefined : sig, numbered }] };
209
216
  }
210
217
  exports.BuiltInProcessorMapper = {
211
218
  [built_in_proc_name_1.BuiltInProcName.Access]: built_in_access_1.processAccess,
@@ -315,6 +322,7 @@ class BuiltIns {
315
322
  processor: (name, args, rootId, data) => mappedProcessor(name, args, rootId, data, config),
316
323
  config,
317
324
  evalHandler: mappedEval,
325
+ processorName: processor,
318
326
  name,
319
327
  nodeId: id
320
328
  }];
@@ -41,5 +41,6 @@ exports.DataMaskingFunctions = [
41
41
  /** The {@link DataMaskingFunctions} as {@link Identifier}s, for the built-in configuration. */
42
42
  exports.DataMaskingFunctionIdentifiers = exports.DataMaskingFunctions.map(([name, pkg]) => identifier_1.Identifier.from([name, pkg]));
43
43
  /** Names to treat as data-masking in the pipe: the {@link DataMaskingFunctions} plus `with`/`within` (own processor). */
44
- exports.DataMaskingFunctionNames = new Set([...exports.DataMaskingFunctions.map(([name]) => name), 'with', 'within']);
44
+ /* a formula (`~`) finds a name no data supplies where it was made, so `lm(y ~ x)` reads `x` */
45
+ exports.DataMaskingFunctionNames = new Set([...exports.DataMaskingFunctions.map(([name]) => name), 'with', 'within', '~']);
45
46
  //# sourceMappingURL=data-masking-functions.js.map
@@ -90,6 +90,8 @@ export declare const LinkToLastGgPlot: {
90
90
  readonly type: "link-to-last-call";
91
91
  readonly callName: RegExp;
92
92
  };
93
+ /** The internal generics: they dispatch in C rather than through `UseMethod`, so the list has to be written down. */
94
+ export declare const InternalGenerics: ReadonlySet<string>;
93
95
  /**
94
96
  * Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
95
97
  * is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
@@ -169,7 +171,7 @@ export declare const WrittenBuiltinDefinitions: [{
169
171
  readonly processor: BuiltInProcName.DefaultReadAllArgs;
170
172
  readonly config: {
171
173
  readonly markArgsAsMasked: NseArguments.All;
172
- readonly sig: [["y", ArgProp.Nse], ["model", number]];
174
+ readonly sig: [["y", 0], ["model", ArgProp.NoDefault]];
173
175
  };
174
176
  readonly assumePrimitive: false;
175
177
  }, {
@@ -2273,9 +2275,14 @@ export declare const WrittenBuiltinDefinitions: [{
2273
2275
  }, {
2274
2276
  readonly type: "function";
2275
2277
  readonly names: [Identifier];
2276
- readonly processor: BuiltInProcName.DefaultReadAllArgs;
2278
+ readonly processor: BuiltInProcName.Default;
2277
2279
  readonly config: {
2278
2280
  readonly libFn: true;
2281
+ readonly readAllArguments: true;
2282
+ readonly hasUnknownSideEffects: {
2283
+ readonly type: "link-to-last-call";
2284
+ readonly callName: RegExp;
2285
+ };
2279
2286
  readonly tags: [SemanticCallTag.File, SemanticCallTag.Writes];
2280
2287
  readonly sig: [["filename", number], ["plot", number], ["device", ArgProp.Flag], ["path", ArgProp.Resource], ["scale", ArgProp.Flag], ["width", ArgProp.Flag], ["height", ArgProp.Flag], ["units", ArgProp.Flag], ["dpi", ArgProp.Flag], ["limitsize", ArgProp.Flag], ["bg", ArgProp.Flag], ["create.dir", ArgProp.Flag], ["...", ArgProp.Flag]];
2281
2288
  };
@@ -2283,9 +2290,14 @@ export declare const WrittenBuiltinDefinitions: [{
2283
2290
  }, {
2284
2291
  readonly type: "function";
2285
2292
  readonly names: [Identifier];
2286
- readonly processor: BuiltInProcName.DefaultReadAllArgs;
2293
+ readonly processor: BuiltInProcName.Default;
2287
2294
  readonly config: {
2288
2295
  readonly libFn: true;
2296
+ readonly readAllArguments: true;
2297
+ readonly hasUnknownSideEffects: {
2298
+ readonly type: "link-to-last-call";
2299
+ readonly callName: RegExp;
2300
+ };
2289
2301
  readonly tags: [SemanticCallTag.File, SemanticCallTag.Writes];
2290
2302
  readonly sig: [["filename", number], ["...", number]];
2291
2303
  };
@@ -4085,7 +4097,9 @@ export declare const WrittenBuiltinDefinitions: [{
4085
4097
  readonly names: [Identifier];
4086
4098
  readonly processor: BuiltInProcName.Default;
4087
4099
  readonly config: {
4088
- readonly hasUnknownSideEffects: true;
4100
+ readonly ambient: {
4101
+ readonly type: AmbientStateAccessType.SetWorkingDirectory;
4102
+ };
4089
4103
  readonly props: number;
4090
4104
  readonly sig: [["dir", number]];
4091
4105
  };
@@ -6278,6 +6292,18 @@ export declare const WrittenBuiltinDefinitions: [{
6278
6292
  readonly sig: [["...", ArgProp.Forced]];
6279
6293
  };
6280
6294
  readonly assumePrimitive: false;
6295
+ }, {
6296
+ readonly type: "function";
6297
+ readonly names: [Identifier];
6298
+ readonly processor: BuiltInProcName.Default;
6299
+ readonly config: {
6300
+ readonly ambient: {
6301
+ readonly type: AmbientStateAccessType.GetWorkingDirectory;
6302
+ };
6303
+ readonly props: CallProp.Ambient;
6304
+ readonly sig: [["...", ArgProp.Forced]];
6305
+ };
6306
+ readonly assumePrimitive: false;
6281
6307
  }, {
6282
6308
  readonly type: "function";
6283
6309
  readonly names: [Identifier];
@@ -6618,7 +6644,6 @@ export declare const WrittenBuiltinDefinitions: [{
6618
6644
  readonly props: CallProp.Scope;
6619
6645
  };
6620
6646
  }, {
6621
- readonly overrides: true;
6622
6647
  readonly type: "function";
6623
6648
  readonly names: [Identifier];
6624
6649
  readonly processor: BuiltInProcName.DefaultReadAllArgs;
@@ -6627,6 +6652,7 @@ export declare const WrittenBuiltinDefinitions: [{
6627
6652
  readonly sig: [["fmt", number], ["...", number]];
6628
6653
  };
6629
6654
  readonly assumePrimitive: true;
6655
+ readonly evalHandler: BuiltInEvalName.StringFn;
6630
6656
  }, {
6631
6657
  readonly overrides: true;
6632
6658
  readonly type: "function";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.LinkToLastGgPlot = exports.BasePrimitiveTopics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotObjectCreate = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
3
+ exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.InternalGenerics = exports.LinkToLastGgPlot = exports.BasePrimitiveTopics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotObjectCreate = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
4
4
  exports.plotFunctionOwners = plotFunctionOwners;
5
5
  exports.namespacePlotFunctions = namespacePlotFunctions;
6
6
  exports.statedSignatures = statedSignatures;
@@ -407,19 +407,19 @@ const LinkToLastPlot = {
407
407
  callName: toRegex(GraphicDeviceOpen.concat(exports.PlotCreate, PlotAddons, exports.GgPlotAddons, exports.TinyPlotAddons))
408
408
  };
409
409
  /** The internal generics: they dispatch in C rather than through `UseMethod`, so the list has to be written down. */
410
- const InternalGenerics = [
410
+ exports.InternalGenerics = new Set([
411
411
  '$', '[', '[[', '+', '-', '*', '/', '^', '%%', '%/%', '==', '!=', '<', '>', '<=', '>=', '&', '|', '!',
412
412
  'c', 'length', 'dim', 'dimnames', 'names', 'max', 'min', 'range', 'sum', 'prod', 'abs', 'sqrt', 'exp',
413
413
  'log', 'floor', 'ceiling', 'round', 'signif', 'trunc', 'cumsum', 'cumprod', 'cummax', 'cummin',
414
414
  'as.character', 'as.integer', 'as.double', 'as.logical', 'as.complex', 'as.numeric', 'as.raw',
415
415
  'is.na', 'is.nan', 'is.finite', 'is.infinite', 'is.matrix', 'is.numeric', 'cbind', 'rbind', 'anyNA', 'as.environment',
416
416
  'as.call', 'is.array', 'log2', 'log10', 'rep', 'seq.int', 'xtfrm'
417
- ];
417
+ ]);
418
418
  /**
419
419
  * Every name R dispatches on: the generated closure generics plus the {@link InternalGenerics} (no R body, so
420
420
  * {@link fnInfoFromSignature} never sees them). `npm run check:generic-labels` checks this against a synced database.
421
421
  */
422
- const RGenerics = new Set([...r_base_packages_generated_1.RBasePackageStore.generics, ...InternalGenerics]);
422
+ const RGenerics = new Set([...r_base_packages_generated_1.RBasePackageStore.generics, ...exports.InternalGenerics]);
423
423
  /** Label every {@link RGenerics} {@link CallProp.Generic}, splitting an entry that mixes them with names that do not dispatch (`&` does, `&&` does not). */
424
424
  function markGenerics(definitions) {
425
425
  const out = [];
@@ -556,7 +556,7 @@ exports.WrittenBuiltinDefinitions = [
556
556
  { type: 'constant', names: [identifier_1.Identifier.from(['month.abb', "base" /* PkgName.Base */])], value: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], assumePrimitive: true },
557
557
  { type: 'constant', names: [identifier_1.Identifier.from(['month.name', "base" /* PkgName.Base */])], value: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], assumePrimitive: true },
558
558
  /* formula: operands are model terms/columns, not variables */
559
- { type: 'function', names: [identifier_1.Identifier.from(['~', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { markArgsAsMasked: known_call_handling_1.NseArguments.All, sig: [['y', built_in_props_1.ArgProp.Nse], ['model', built_in_props_1.ArgProp.NoDefault | built_in_props_1.ArgProp.Nse]] }, assumePrimitive: false },
559
+ { type: 'function', names: [identifier_1.Identifier.from(['~', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { markArgsAsMasked: known_call_handling_1.NseArguments.All, sig: [['y', 0], ['model', built_in_props_1.ArgProp.NoDefault]] }, assumePrimitive: false },
560
560
  /* cohortBuilder has a `filter` too, and built-ins go by name, so dplyr's entry below wins in the environment
561
561
  while this one still states what cohortBuilder's does */
562
562
  { type: 'function', names: [identifier_1.Identifier.from(['filter', "cohortBuilder" /* PkgName.CohortBuilder */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, props: built_in_props_1.CallProp.Pure, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
@@ -654,7 +654,7 @@ exports.WrittenBuiltinDefinitions = [
654
654
  'solve', 'det', 'eigen', 'aperm',
655
655
  /* string */
656
656
  'grep', 'sub', 'gsub', 'substr', 'substring', 'strsplit', 'strrep', 'chartr', 'strtoi', 'shQuote',
657
- 'regexpr', 'gregexpr', 'regexec', 'format', 'sprintf', 'formatC',
657
+ 'regexpr', 'gregexpr', 'regexec', 'format', 'formatC',
658
658
  /* regmatches yields a substring of its subject, so what flows in flows out */
659
659
  'regmatches'
660
660
  ]),
@@ -840,12 +840,8 @@ exports.WrittenBuiltinDefinitions = [
840
840
  { type: 'function', names: [identifier_1.Identifier.from(['writeWorksheetToFile', "XLConnect" /* PkgName.XlConnect */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
841
841
  { type: 'function', names: [identifier_1.Identifier.from(['visSave', "visNetwork" /* PkgName.VisNetwork */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['graph', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
842
842
  { type: 'function', names: [identifier_1.Identifier.from(['save_graph', "DiagrammeR" /* PkgName.DiagrammeR */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['graph', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
843
- { type: 'function', names: [identifier_1.Identifier.from(['ggsave', "ggplot2" /* PkgName.GgPlot2 */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [
844
- ['filename', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['plot', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['device', built_in_props_1.ArgProp.Flag], ['path', built_in_props_1.ArgProp.Resource],
845
- ['scale', built_in_props_1.ArgProp.Flag], ['width', built_in_props_1.ArgProp.Flag], ['height', built_in_props_1.ArgProp.Flag], ['units', built_in_props_1.ArgProp.Flag], ['dpi', built_in_props_1.ArgProp.Flag], ['limitsize', built_in_props_1.ArgProp.Flag],
846
- ['bg', built_in_props_1.ArgProp.Flag], ['create.dir', built_in_props_1.ArgProp.Flag], ['...', built_in_props_1.ArgProp.Flag]
847
- ] }, assumePrimitive: false },
848
- { type: 'function', names: [identifier_1.Identifier.from(['ggsave2', "cowplot" /* PkgName.Cowplot */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['filename', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
843
+ { type: 'function', names: [identifier_1.Identifier.from(['ggsave', "ggplot2" /* PkgName.GgPlot2 */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, readAllArguments: true, hasUnknownSideEffects: exports.LinkToLastGgPlot, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['filename', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['plot', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['device', built_in_props_1.ArgProp.Flag], ['path', built_in_props_1.ArgProp.Resource], ['scale', built_in_props_1.ArgProp.Flag], ['width', built_in_props_1.ArgProp.Flag], ['height', built_in_props_1.ArgProp.Flag], ['units', built_in_props_1.ArgProp.Flag], ['dpi', built_in_props_1.ArgProp.Flag], ['limitsize', built_in_props_1.ArgProp.Flag], ['bg', built_in_props_1.ArgProp.Flag], ['create.dir', built_in_props_1.ArgProp.Flag], ['...', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
844
+ { type: 'function', names: [identifier_1.Identifier.from(['ggsave2', "cowplot" /* PkgName.Cowplot */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, readAllArguments: true, hasUnknownSideEffects: exports.LinkToLastGgPlot, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['filename', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
849
845
  { type: 'function', names: [identifier_1.Identifier.from(['write_json', "jsonlite" /* PkgName.Jsonlite */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['path', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
850
846
  { type: 'function', names: [identifier_1.Identifier.from(['fwrite', "data.table" /* PkgName.DataTable */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
851
847
  { type: 'function', names: [identifier_1.Identifier.from(['write_xlsx', "writexl" /* PkgName.Writexl */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['path', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
@@ -1026,7 +1022,7 @@ exports.WrittenBuiltinDefinitions = [
1026
1022
  { type: 'function', names: identifier_1.Identifier.fromAll("grDevices" /* PkgName.GrDevices */, ['dev.set', 'dev.next', 'dev.prev']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Configures, libFn: true, ambient: { type: "switch-device" /* AmbientStateAccessType.SwitchDevice */ }, tags: [built_in_props_1.SemanticCallTag.Graphics], sig: [['which', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1027
1023
  { type: 'function', names: ['('], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { keepArgumentOut: true, props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Alias]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Group },
1028
1024
  { type: 'function', names: [identifier_1.Identifier.from(['load_all', "pkgload" /* PkgName.PkgLoad */]), identifier_1.Identifier.from(['load_all', "devtools" /* PkgName.Devtools */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, props: built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.Invisible, sig: [['path', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1029
- { type: 'function', names: [identifier_1.Identifier.from(['setwd', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Ambient | built_in_props_1.CallProp.Configures, sig: [['dir', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1025
+ { type: 'function', names: [identifier_1.Identifier.from(['setwd', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Ambient | built_in_props_1.CallProp.Configures, sig: [['dir', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1030
1026
  { type: 'function', names: [identifier_1.Identifier.from(['set.seed', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "set-rng" /* AmbientStateAccessType.SetRng */ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Configures, tags: [built_in_props_1.SemanticCallTag.Random], sig: [['seed', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['normal.kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['sample.kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1031
1027
  { type: 'function', names: [identifier_1.Identifier.from(['RNGkind', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "set-rng" /* AmbientStateAccessType.SetRng */, kindFrom: 0 }, props: built_in_props_1.CallProp.Configures, tags: [built_in_props_1.SemanticCallTag.Random], sig: [['kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['normal.kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['sample.kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1032
1028
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['body', 'formals']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, props: built_in_props_1.CallProp.Lang, sig: [['fun', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: true },
@@ -1357,7 +1353,8 @@ exports.WrittenBuiltinDefinitions = [
1357
1353
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['dyn.load', 'getNativeSymbolInfo']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Ffi, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1358
1354
  { type: 'function', names: [identifier_1.Identifier.from(['sourceCpp', "Rcpp" /* PkgName.Rcpp */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, props: built_in_props_1.CallProp.Ffi | built_in_props_1.CallProp.Invisible, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Reads], sig: [['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
1359
1355
  /* ambient state: options, environment variables, the clock, the session itself */
1360
- { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['Sys.getenv', 'Sys.info', 'Sys.getpid', 'getwd', 'getRversion', 'R.Version', 'Sys.time', 'Sys.Date', 'Sys.timezone', 'date', 'proc.time', 'interactive']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Ambient, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1356
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['Sys.getenv', 'Sys.info', 'Sys.getpid', 'getRversion', 'R.Version', 'Sys.time', 'Sys.Date', 'Sys.timezone', 'date', 'proc.time', 'interactive']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Ambient, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1357
+ { type: 'function', names: [identifier_1.Identifier.from(['getwd', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */ }, props: built_in_props_1.CallProp.Ambient, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1361
1358
  { type: 'function', names: [identifier_1.Identifier.from(['getOption', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "get-option" /* AmbientStateAccessType.GetOption */ }, props: built_in_props_1.CallProp.Ambient, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1362
1359
  { type: 'function', names: [identifier_1.Identifier.from(['commandArgs', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Ambient, tags: [built_in_props_1.SemanticCallTag.CommandLine], sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1363
1360
  /* system commands */
@@ -1418,7 +1415,7 @@ exports.WrittenBuiltinDefinitions = [
1418
1415
  { type: 'replacement', suffixes: ['<-', '<<-'], names: ['$', '@'], config: { readIndices: false, props: built_in_props_1.CallProp.Scope } },
1419
1416
  /* the string and shape functions R declares formals for, restated one by one: the group above gives them
1420
1417
  what they do, this gives them the arguments they do it with (the names are R's own) */
1421
- { overrides: true, type: 'function', names: [identifier_1.Identifier.from(['sprintf', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['fmt', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1418
+ { type: 'function', names: [identifier_1.Identifier.from(['sprintf', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['fmt', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.StringFn },
1422
1419
  { overrides: true, type: 'function', names: [identifier_1.Identifier.from(['format', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { ambient: PrintDispatched, props: built_in_props_1.CallProp.Pure, sig: SigXDots }, assumePrimitive: true },
1423
1420
  { overrides: true, type: 'function', names: [identifier_1.Identifier.from(['grep', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['pattern', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['ignore.case', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['perl', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['value', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['fixed', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['useBytes', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['invert', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
1424
1421
  { overrides: true, type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['sub', 'gsub']), processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, tags: [built_in_props_1.SemanticCallTag.Edits], sig: [['pattern', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['replacement', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['ignore.case', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['perl', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['fixed', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['useBytes', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
@@ -365,6 +365,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
365
365
  const value = resolveIdToValue(sequence.info.id, { graph, idMap, ctx, blocked });
366
366
  return (0, r_value_1.isTop)(value) ? r_value_1.Top : (0, set_constants_1.setOf)(iteratedElements(value));
367
367
  }
368
+ const start = id;
368
369
  const queue = new visiting_queue_1.VisitingQueue(10);
369
370
  const clean = ctx.env.makeCleanEnv();
370
371
  const cleanFingerprint = ctx.env.getCleanEnvFingerprint();
@@ -380,7 +381,9 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
380
381
  continue;
381
382
  }
382
383
  const cds = vertex.cds;
383
- for (const cd of cds ?? []) {
384
+ /* a read in a loop sees the same value every round unless a definition in the loop reaches it, which the walk meets */
385
+ const loopedRead = id === start && vertex_1.DfgVertex.isUse(vertex);
386
+ for (const cd of loopedRead ? [] : cds ?? []) {
384
387
  const target = graph.idMap?.get(cd.id);
385
388
  if (target === undefined) {
386
389
  continue;
@@ -390,7 +393,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
390
393
  break;
391
394
  }
392
395
  }
393
- if (!forceTop && (cds?.length === 0 && isNestedInLoop(idMap.get(id), idMap))) {
396
+ if (!forceTop && !loopedRead && (cds?.length === 0 && isNestedInLoop(idMap.get(id), idMap))) {
394
397
  forceTop = true;
395
398
  }
396
399
  if (forceTop) {
@@ -64,7 +64,7 @@ exports.NodeValue = {
64
64
  sole: general_1.soleValue,
65
65
  /** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
66
66
  soleOf(id, against, type, overrides) {
67
- return (0, general_1.soleValue)((0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, infoOf(against, overrides))), type);
67
+ return exports.NodeValue.sole((0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(id, infoOf(against, overrides))), type);
68
68
  },
69
69
  };
70
70
  //# sourceMappingURL=node-value.js.map
@@ -21,6 +21,7 @@ const string_constants_1 = require("../values/string/string-constants");
21
21
  const resolve_helper_1 = require("../../environments/resolve-helper");
22
22
  const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
23
23
  const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
24
+ const applied_arguments_1 = require("../../graph/applied-arguments");
24
25
  /**
25
26
  * The index of the argument of `vertex` that binds the formal `argumentName`, R's matching when the formals are known and the `argumentIndex`-th unnamed argument otherwise.
26
27
  * Pass the `formals` of the call when they are known already, which saves looking them up again.
@@ -49,6 +50,7 @@ function boundArgumentIndex(graph, vertex, argumentIndex, argumentName, ctx, for
49
50
  * Pass the `formals` of the call when they are known already, see {@link boundArgumentIndex}.
50
51
  */
51
52
  function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue, ctx, formals) {
53
+ vertex = (0, applied_arguments_1.appliedArguments)(graph, vertex);
52
54
  if (argumentName && argumentIndex !== 'unnamed') {
53
55
  argumentIndex = boundArgumentIndex(graph, vertex, argumentIndex, argumentName, ctx, formals);
54
56
  }
@@ -61,6 +61,11 @@ export declare const StringFns: {
61
61
  };
62
62
  readonly fold: (parts: string[], fsep: string) => string;
63
63
  };
64
+ readonly sprintf: {
65
+ readonly pkg: PkgName.Base;
66
+ readonly params: readonly ["fmt", "..."];
67
+ readonly fold: (fmt: string, parts?: string[]) => string | undefined;
68
+ };
64
69
  readonly here: {
65
70
  readonly pkg: PkgName.Here;
66
71
  readonly params: readonly ["..."];
@@ -148,6 +153,11 @@ export declare const StringFold: {
148
153
  };
149
154
  readonly fold: (parts: string[], fsep: string) => string;
150
155
  };
156
+ readonly sprintf: {
157
+ readonly pkg: PkgName.Base;
158
+ readonly params: readonly ["fmt", "..."];
159
+ readonly fold: (fmt: string, parts?: string[]) => string | undefined;
160
+ };
151
161
  readonly here: {
152
162
  readonly pkg: PkgName.Here;
153
163
  readonly params: readonly ["..."];