@eagleoutice/flowr 2.17.12 → 2.17.13
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.
- package/config.d.ts +1 -0
- package/config.js +4 -2
- package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-functions.js +2 -0
- package/dataflow/environments/default-builtin-config/guards.js +3 -1
- package/dataflow/environments/default-builtin-config/index.d.ts +1 -1
- package/dataflow/extractor.js +58 -0
- package/dataflow/fn/guards/built-in-guards.js +4 -4
- package/dataflow/fn/guards/call-contracts.js +8 -8
- package/dataflow/fn/guards/condition-grouping.js +4 -3
- package/dataflow/fn/guards/function-guards.js +103 -97
- package/dataflow/fn/guards/group-method-guards.js +10 -8
- package/dataflow/fn/guards/guard-claims.js +152 -128
- package/dataflow/fn/guards/guard-knowledge.js +19 -18
- package/dataflow/fn/guards/guard-term-syntax.js +13 -12
- package/dataflow/fn/guards/guard-term.d.ts +71 -0
- package/dataflow/fn/guards/guard-term.js +183 -75
- package/dataflow/graph/graph.d.ts +9 -0
- package/dataflow/graph/graph.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +6 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +9 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +35 -3
- package/documentation/wiki-interface.js +1 -0
- package/package.json +1 -1
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
|
@@ -115,7 +115,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
115
115
|
if (sourceFileArgument === undefined) {
|
|
116
116
|
logger_1.dataflowLogger.warn('Expected a file argument for source, skipping');
|
|
117
117
|
const unknown = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
118
|
-
(
|
|
118
|
+
bindsUnseen(unknown, rootId, data);
|
|
119
119
|
return unknown;
|
|
120
120
|
}
|
|
121
121
|
const localArg = bound.get(config.envIn ?? 'local');
|
|
@@ -130,7 +130,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
130
130
|
const withAmbient = () => config.ambient === undefined ? information : (0, built_in_ambient_state_1.applyAmbientEffects)(information, args, rootId, data, config.ambient);
|
|
131
131
|
if (!config.forceFollow && data.ctx.config.ignoreSourceCalls) {
|
|
132
132
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source call ${JSON.stringify(sourceFileArgument)} (disabled in config file)`);
|
|
133
|
-
(
|
|
133
|
+
bindsUnseen(information, rootId, data);
|
|
134
134
|
return withAmbient();
|
|
135
135
|
}
|
|
136
136
|
let sourceFile;
|
|
@@ -143,7 +143,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
143
143
|
const path = sourceFile?.length === 1 ? r_string_1.RString.unquote(sourceFile[0]) : undefined;
|
|
144
144
|
const filepath = path ? findSource(data.ctx.config.solver.resolveSource, path, data) : undefined;
|
|
145
145
|
if (localArg !== undefined && !r_logical_1.RLogical.is(localArg.value) && resolution === undefined) {
|
|
146
|
-
(
|
|
146
|
+
bindsUnseen(information, rootId, data);
|
|
147
147
|
return withAmbient();
|
|
148
148
|
}
|
|
149
149
|
if (filepath !== undefined && filepath.length > 0) {
|
|
@@ -183,9 +183,18 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
183
183
|
return routed;
|
|
184
184
|
}
|
|
185
185
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Non-constant argument ${JSON.stringify(sourceFile)} for source is currently not supported, skipping`);
|
|
186
|
-
(
|
|
186
|
+
bindsUnseen(information, rootId, data);
|
|
187
187
|
return withAmbient();
|
|
188
188
|
}
|
|
189
|
+
/** Code we cannot see has an unknown side effect, and binds methods only if `solver.resolveSource.unseenMethods` is set. */
|
|
190
|
+
function bindsUnseen(information, rootId, data) {
|
|
191
|
+
if (data.ctx.config.solver.resolveSource?.unseenMethods) {
|
|
192
|
+
(0, built_in_expression_list_1.bindsUnknownNames)(information.graph, information.environment, rootId);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
189
198
|
/** The reads of code evaluated in the global environment, which no frame of the function running it binds; the `call`'s own reads stay as they are. */
|
|
190
199
|
function readGlobally(result, call) {
|
|
191
200
|
const own = new Set([...call.in, ...call.unknownReferences]);
|
|
@@ -207,20 +216,20 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId, eva
|
|
|
207
216
|
const textRequest = data.ctx.files.resolveRequest(request);
|
|
208
217
|
if (textRequest === undefined && request.request === 'file') {
|
|
209
218
|
logger_1.dataflowLogger.warn(`Failed to analyze sourced file ${JSON.stringify(request)}: file does not exist`);
|
|
210
|
-
(
|
|
219
|
+
bindsUnseen(information, rootId, data);
|
|
211
220
|
return information;
|
|
212
221
|
}
|
|
213
222
|
(0, assert_1.guard)(textRequest !== undefined, `Expected text request to be defined for sourced file ${JSON.stringify(request)}`);
|
|
214
223
|
const ext = textRequest.path ? /\.[^.]*$/.exec(textRequest.path)?.[0].toLowerCase() : undefined;
|
|
215
224
|
if (ext !== undefined && ext !== '.r') {
|
|
216
225
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source of non-R file ${JSON.stringify(textRequest.path)}`);
|
|
217
|
-
(
|
|
226
|
+
bindsUnseen(information, rootId, data);
|
|
218
227
|
return information;
|
|
219
228
|
}
|
|
220
229
|
const gasLevel = data.ctx.gas.checkGas(gas_1.GasFeatureKey.Source);
|
|
221
230
|
if (gasLevel >= 2 /* GasLevel.Critical */) {
|
|
222
231
|
logger_1.dataflowLogger.warn(`Skipping source of ${JSON.stringify(request)} due to resource pressure (gas: critical). See ${gas_1.GasWikiRef}`);
|
|
223
|
-
(
|
|
232
|
+
bindsUnseen(information, rootId, data);
|
|
224
233
|
return information;
|
|
225
234
|
}
|
|
226
235
|
else if (gasLevel >= 1 /* GasLevel.Problematic */) {
|
|
@@ -257,7 +266,7 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId, eva
|
|
|
257
266
|
catch (e) {
|
|
258
267
|
logger_1.dataflowLogger.error(`Failed to analyze sourced file ${JSON.stringify(request)}, skipping: ${e.message}`);
|
|
259
268
|
logger_1.dataflowLogger.error(e.stack);
|
|
260
|
-
(
|
|
269
|
+
bindsUnseen(information, rootId, data);
|
|
261
270
|
return information;
|
|
262
271
|
}
|
|
263
272
|
// take the entry point as well as all the written references, and give them a control dependency to the source call to show that they are conditional
|
|
@@ -304,10 +313,11 @@ function standaloneSourceFile(idx, file, data, information) {
|
|
|
304
313
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, file.root.info.id);
|
|
305
314
|
return information;
|
|
306
315
|
}
|
|
316
|
+
/* `sourceRequest` appends the file itself, so it runs at the top level just like the first file (e.g., auto-printing) */
|
|
307
317
|
return sourceRequest('file-' + idx, file, {
|
|
308
318
|
...data,
|
|
309
319
|
environment: information.environment,
|
|
310
|
-
referenceChain: [
|
|
320
|
+
referenceChain: []
|
|
311
321
|
}, information, false, undefined, false, false);
|
|
312
322
|
}
|
|
313
323
|
/** Folds the results of analyzing sourced code back into the information of the call that asked for it, which `eval` and the string templates both need: the code contributes everything it reads, writes, and leaves open. */
|
|
@@ -68,11 +68,35 @@ function processWithEnv(name, args, rootId, data) {
|
|
|
68
68
|
const envirResolution = (0, built_in_envir_utils_1.envirOf)(envirRouting);
|
|
69
69
|
if (!envirResolution) {
|
|
70
70
|
const fallback = markAsMaskedFallback(name, args, rootId, data, exprArg.value);
|
|
71
|
+
const isWithin = identifier_1.Identifier.getName(name.content) === 'within';
|
|
72
|
+
if (isWithin) {
|
|
73
|
+
/* the copy `within` returns carries every variable `expr` defines, so the call needs all of these definitions, not just the last */
|
|
74
|
+
for (const [defId] of fallback.graph.verticesOfType(vertex_1.VertexType.VariableDefinition)) {
|
|
75
|
+
fallback.graph.addEdge(rootId, defId, edge_1.EdgeType.Reads);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/*
|
|
79
|
+
* `within` only has methods for lists and data frames and works on a copy of them, so what `expr` writes into a value
|
|
80
|
+
* the program defines (but we cannot track as an environment) never reaches the caller; a parameter is left alone,
|
|
81
|
+
* as the caller may hand in anything
|
|
82
|
+
*/
|
|
83
|
+
if (isWithin && envirRouting === 'ambiguous' && !mayBeParameter(dataArg.value, data)) {
|
|
84
|
+
return fallback;
|
|
85
|
+
}
|
|
86
|
+
const defines = !fallback.graph.verticesOfType(vertex_1.VertexType.VariableDefinition).next().done;
|
|
71
87
|
/* only a definition or a call we cannot see into (a closure of `data`) can write to a `data` we cannot pin down */
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
88
|
+
if (!defines && !callsOpaque(fallback.graph, rootId)) {
|
|
89
|
+
return fallback;
|
|
74
90
|
}
|
|
75
|
-
|
|
91
|
+
/*
|
|
92
|
+
* a definition in `expr` lands in `data` if it is an environment, which may be the global one, so only a definition
|
|
93
|
+
* makes the call an unknown side effect; a call we cannot see into is no more opaque than the same call outside of `with`,
|
|
94
|
+
* it can at most change `data`, which `mayWriteInto` covers
|
|
95
|
+
*/
|
|
96
|
+
if (defines && (0, built_in_envir_utils_1.unknownIfAmbiguous)(envirRouting, fallback, rootId, dataArg.value.info.id)) {
|
|
97
|
+
return fallback;
|
|
98
|
+
}
|
|
99
|
+
return mayWriteInto(dataArg.value, fallback, rootId, data);
|
|
76
100
|
}
|
|
77
101
|
const pipedData = (0, common_1.isPipedArgument)(dataArg, rootId, data);
|
|
78
102
|
const dfDataArg = pipedData ? info_1.DataflowInformation.initialize(rootId, data) : (0, processor_1.processDataflowFor)(dataArg.value, data);
|
|
@@ -192,6 +216,14 @@ function processWithLiteralList(name, rootId, data, dataNode, expr, elements) {
|
|
|
192
216
|
function callsOpaque(graph, rootId) {
|
|
193
217
|
return graph.verticesOfType(vertex_1.VertexType.FunctionCall).some(([id, vertex]) => id !== rootId && !vertex.onlyBuiltin);
|
|
194
218
|
}
|
|
219
|
+
/** whether `dataNode` is not a symbol, or a symbol of which some definition is a parameter of the enclosing function */
|
|
220
|
+
function mayBeParameter(dataNode, data) {
|
|
221
|
+
if (!r_symbol_1.RSymbol.is(dataNode)) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
const defs = resolve_helper_1.Resolve.byNameAndType(dataNode.content, data.environment, identifier_1.ReferenceType.Variable);
|
|
225
|
+
return defs === undefined || defs.some(d => (d.type & identifier_1.ReferenceType.Parameter) !== 0);
|
|
226
|
+
}
|
|
195
227
|
/** `data` may be an untracked environment `expr` writes into, so later reads of its variable see the call as a maybe redefinition. */
|
|
196
228
|
function mayWriteInto(dataNode, result, rootId, data) {
|
|
197
229
|
keepCallFor(result.out, result.graph, rootId);
|
|
@@ -229,6 +229,7 @@ The schema below documents every option; the ones you most likely want are:
|
|
|
229
229
|
- ${ctx.linkConfig('semantics.environment.overwriteBuiltIns')}: overwrite _flowR_'s handling of built-in functions, or clear the preset definitions entirely.
|
|
230
230
|
See [Configure BuiltIn Semantics](#configure-builtin-semantics) for more information.
|
|
231
231
|
- ${ctx.linkConfig('semantics.ambient.drawingWritesDevice')}: whether calls drawing on a graphics device (e.g., \`plot\`) count as writing the device in the ambient state queries.
|
|
232
|
+
- ${ctx.linkConfig('solver.resolveSource.unseenMethods')}: whether a sourced file _flowR_ cannot read may bind S3/S4 methods that later calls dispatch to (sound, but chains every such call, off by default).
|
|
232
233
|
- ${ctx.linkConfig('solver.variables')}: how to resolve variables and their values (${Object.values(config_1.VariableResolve).map(v => `\`${v}\``).join(', ')}).
|
|
233
234
|
- ${ctx.linkConfig('engines')} and ${ctx.linkConfig('defaultEngine')}: the engines used to interact with R code, see the ${ctx.linkPage('wiki/Engines', 'Engines wiki page')}.
|
|
234
235
|
- ${ctx.linkConfig('project.implicitSources')}: the files a framework loads without any \`source()\` call, in the order in which they are
|
package/package.json
CHANGED
package/util/flowr-version.d.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import { SemVer } from 'semver';
|
|
6
|
-
export declare const versionDate = "2026-11-
|
|
6
|
+
export declare const versionDate = "2026-11-25T20:19:23Z";
|
|
7
7
|
/** Retrieves the current flowR version as a new {@link SemVer} object. */
|
|
8
8
|
export declare function flowrVersion(): SemVer;
|
package/util/flowr-version.js
CHANGED
|
@@ -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.
|
|
11
|
+
const version = '2.17.13';
|
|
12
12
|
// this is automatically replaced with the release date by release-it (scripts/bump-version.ts)
|
|
13
|
-
exports.versionDate = '2026-11-
|
|
13
|
+
exports.versionDate = '2026-11-25T20:19:23Z';
|
|
14
14
|
/** Retrieves the current flowR version as a new {@link SemVer} object. */
|
|
15
15
|
function flowrVersion() {
|
|
16
16
|
return new semver_1.SemVer(version);
|