@eagleoutice/flowr 2.17.5 → 2.17.6

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 (357) hide show
  1. package/README.md +13 -51
  2. package/abstract-interpretation/absint-inference.d.ts +4 -4
  3. package/abstract-interpretation/absint-inference.js +11 -11
  4. package/abstract-interpretation/abstract-semantics.d.ts +2 -1
  5. package/abstract-interpretation/branch-paths-interpreter.d.ts +1 -0
  6. package/abstract-interpretation/branch-paths-interpreter.js +60 -0
  7. package/abstract-interpretation/branch-paths.d.ts +60 -0
  8. package/abstract-interpretation/branch-paths.js +120 -0
  9. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +6 -1
  10. package/abstract-interpretation/data-frame/dataframe-semantics.js +60 -1
  11. package/abstract-interpretation/data-frame/semantics.js +4 -10
  12. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
  13. package/cli/repl/core.js +51 -0
  14. package/control-flow/cfg-dead-code.js +12 -7
  15. package/data/packed.d.ts +10 -0
  16. package/data/packed.js +33 -0
  17. package/data/r-base-guards.generated.d.ts +7 -0
  18. package/data/r-base-guards.generated.js +12 -0
  19. package/data/r-datasets.generated.d.ts +4 -0
  20. package/data/r-datasets.generated.js +10 -0
  21. package/data/r-formals.generated.d.ts +4 -0
  22. package/data/r-formals.generated.js +10 -0
  23. package/data/r-group-method-guards.generated.d.ts +3 -0
  24. package/data/r-group-method-guards.generated.js +8 -0
  25. package/dataflow/environments/ambient-effect.d.ts +1000 -0
  26. package/dataflow/environments/ambient-effect.js +234 -0
  27. package/dataflow/environments/ambient-state-name.d.ts +45 -2
  28. package/dataflow/environments/ambient-state-name.js +61 -3
  29. package/dataflow/environments/apply-kill.js +11 -4
  30. package/dataflow/environments/built-in-kinds.d.ts +4 -46
  31. package/dataflow/environments/built-in-kinds.js +6 -2
  32. package/dataflow/environments/built-in-props.d.ts +16 -4
  33. package/dataflow/environments/built-in-props.js +11 -3
  34. package/dataflow/environments/built-in.d.ts +6 -1
  35. package/dataflow/environments/built-in.js +13 -36
  36. package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
  37. package/dataflow/environments/default-builtin-config/base-functions.js +110 -52
  38. package/dataflow/environments/default-builtin-config/base-language.d.ts +1 -1
  39. package/dataflow/environments/default-builtin-config/base-language.js +11 -8
  40. package/dataflow/environments/default-builtin-config/dev-tooling.js +1 -1
  41. package/dataflow/environments/default-builtin-config/file-io.js +6 -4
  42. package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +1 -1
  43. package/dataflow/environments/default-builtin-config/graphics-devices.js +24 -14
  44. package/dataflow/environments/default-builtin-config/guard-builders.d.ts +16 -0
  45. package/dataflow/environments/default-builtin-config/guard-builders.js +29 -0
  46. package/dataflow/environments/default-builtin-config/guards-primitive-lang.d.ts +15 -0
  47. package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +228 -0
  48. package/dataflow/environments/default-builtin-config/guards-primitive-ops.d.ts +11 -0
  49. package/dataflow/environments/default-builtin-config/guards-primitive-ops.js +154 -0
  50. package/dataflow/environments/default-builtin-config/guards.d.ts +9 -0
  51. package/dataflow/environments/default-builtin-config/guards.js +211 -0
  52. package/dataflow/environments/default-builtin-config/index.d.ts +3 -3
  53. package/dataflow/environments/default-builtin-config/index.js +22 -7
  54. package/dataflow/environments/default-builtin-config/media-formats.js +4 -4
  55. package/dataflow/environments/default-builtin-config/package-spatial.js +2 -1
  56. package/dataflow/environments/default-builtin-config/package-tidyverse.js +3 -2
  57. package/dataflow/environments/default-builtin-config/package-utils.d.ts +1 -1
  58. package/dataflow/environments/default-builtin-config/package-utils.js +5 -2
  59. package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
  60. package/dataflow/environments/default-builtin-config/parallel-execution.js +3 -1
  61. package/dataflow/environments/default-builtin-config/r-formals.d.ts +13 -0
  62. package/dataflow/environments/default-builtin-config/r-formals.js +110 -0
  63. package/dataflow/environments/default-builtin-config/shared-configs.d.ts +138 -77
  64. package/dataflow/environments/default-builtin-config/shared-configs.js +52 -88
  65. package/dataflow/environments/default-builtin-config/statistics.d.ts +1 -1
  66. package/dataflow/environments/default-builtin-config/statistics.js +4 -1
  67. package/dataflow/environments/diff.js +5 -2
  68. package/dataflow/environments/environment.d.ts +20 -0
  69. package/dataflow/environments/environment.js +39 -4
  70. package/dataflow/environments/group-generics.d.ts +5 -1
  71. package/dataflow/environments/group-generics.js +13 -3
  72. package/dataflow/environments/guard-facts.d.ts +169 -0
  73. package/dataflow/environments/guard-facts.js +26 -0
  74. package/dataflow/environments/identifier.d.ts +9 -1
  75. package/dataflow/environments/identifier.js +5 -0
  76. package/dataflow/environments/pkg-name.d.ts +1 -0
  77. package/dataflow/environments/query-fn-props.d.ts +3 -5
  78. package/dataflow/environments/query-fn-props.js +44 -21
  79. package/dataflow/environments/removal-marker.d.ts +2 -0
  80. package/dataflow/environments/removal-marker.js +5 -0
  81. package/dataflow/eval/resolve/resolve-strings.d.ts +2 -5
  82. package/dataflow/eval/resolve/resolve-strings.js +2 -2
  83. package/dataflow/extractor.js +24 -15
  84. package/dataflow/fn/condition-handlers.d.ts +2 -0
  85. package/dataflow/fn/condition-handlers.js +3 -1
  86. package/dataflow/fn/frame-reflection.d.ts +4 -2
  87. package/dataflow/fn/frame-reflection.js +16 -0
  88. package/dataflow/fn/function-props.js +15 -22
  89. package/dataflow/fn/function-semantics.d.ts +31 -1
  90. package/dataflow/fn/function-semantics.js +15 -0
  91. package/dataflow/fn/guards/built-in-guards.d.ts +112 -0
  92. package/dataflow/fn/guards/built-in-guards.js +199 -0
  93. package/dataflow/fn/guards/call-contracts.d.ts +97 -0
  94. package/dataflow/fn/guards/call-contracts.js +331 -0
  95. package/dataflow/fn/guards/condition-grouping.d.ts +20 -0
  96. package/dataflow/fn/guards/condition-grouping.js +135 -0
  97. package/dataflow/fn/guards/function-guards.d.ts +112 -0
  98. package/dataflow/fn/guards/function-guards.js +1549 -0
  99. package/dataflow/fn/guards/group-method-guards.d.ts +28 -0
  100. package/dataflow/fn/guards/group-method-guards.js +56 -0
  101. package/dataflow/fn/guards/guard-claims.d.ts +125 -0
  102. package/dataflow/fn/guards/guard-claims.js +678 -0
  103. package/dataflow/fn/guards/guard-knowledge.d.ts +41 -0
  104. package/dataflow/fn/guards/guard-knowledge.js +180 -0
  105. package/dataflow/fn/guards/guard-term-syntax.d.ts +9 -0
  106. package/dataflow/fn/guards/guard-term-syntax.js +210 -0
  107. package/dataflow/fn/guards/guard-term.d.ts +136 -0
  108. package/dataflow/fn/guards/guard-term.js +550 -0
  109. package/dataflow/fn/guards/stated-guards.d.ts +13 -0
  110. package/dataflow/fn/guards/stated-guards.js +35 -0
  111. package/dataflow/fn/higher-order-function.d.ts +2 -0
  112. package/dataflow/fn/higher-order-function.js +1 -0
  113. package/dataflow/fn/strict-function.d.ts +4 -0
  114. package/dataflow/fn/strict-function.js +66 -17
  115. package/dataflow/graph/ambient-access.d.ts +4 -1
  116. package/dataflow/graph/ambient-access.js +8 -2
  117. package/dataflow/graph/closure-frames.js +1 -1
  118. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  119. package/dataflow/graph/dataflowgraph-builder.js +2 -2
  120. package/dataflow/graph/df-helper.d.ts +6 -0
  121. package/dataflow/graph/df-helper.js +15 -0
  122. package/dataflow/graph/graph.d.ts +12 -6
  123. package/dataflow/graph/graph.js +21 -28
  124. package/dataflow/info.d.ts +2 -1
  125. package/dataflow/info.js +3 -1
  126. package/dataflow/internal/dispatch-linking.d.ts +3 -1
  127. package/dataflow/internal/dispatch-linking.js +1 -0
  128. package/dataflow/internal/linker.d.ts +2 -0
  129. package/dataflow/internal/linker.js +115 -6
  130. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
  131. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +5 -2
  132. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +2 -1
  133. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -57
  134. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +471 -295
  135. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +13 -1
  136. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -0
  137. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +106 -19
  138. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  139. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +24 -3
  140. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +1 -1
  141. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +33 -11
  142. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +4 -0
  143. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +4 -4
  144. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +23 -7
  145. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
  146. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +19 -2
  147. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +347 -46
  148. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  149. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +5 -0
  150. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +110 -16
  151. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +2 -0
  152. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +9 -2
  153. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  154. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -2
  155. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -0
  156. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +28 -0
  157. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +16 -6
  158. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +6 -1
  159. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +37 -2
  160. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +4 -0
  161. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +19 -1
  162. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
  163. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +55 -11
  164. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -2
  165. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +11 -10
  166. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -1
  167. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +8 -0
  168. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +64 -7
  169. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +1 -1
  170. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +160 -20
  171. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
  172. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +6 -0
  173. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +142 -4
  174. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  175. package/dataflow/internal/process/functions/call/quoted.js +23 -4
  176. package/dataflow/processor.d.ts +2 -0
  177. package/documentation/data/dfg/doc-ambient.d.ts +4 -0
  178. package/documentation/data/dfg/doc-ambient.js +74 -0
  179. package/documentation/wiki-dataflow-graph.js +10 -4
  180. package/documentation/wiki-linter.js +12 -0
  181. package/documentation/wiki-query.js +112 -1
  182. package/linter/linter-rules.d.ts +41 -1
  183. package/linter/linter-rules.js +5 -1
  184. package/linter/rules/call-contracts.d.ts +40 -0
  185. package/linter/rules/call-contracts.js +56 -0
  186. package/linter/rules/cmd-check/bogus-return.js +1 -1
  187. package/linter/rules/cmd-check/call-arguments.js +5 -6
  188. package/linter/rules/cmd-check/cmd-check-util.d.ts +0 -6
  189. package/linter/rules/cmd-check/cmd-check-util.js +0 -28
  190. package/linter/rules/cmd-check/package-hooks.js +2 -1
  191. package/linter/rules/cmd-check/s-three-method-consistency.js +1 -1
  192. package/linter/rules/interactive-functions.d.ts +30 -0
  193. package/linter/rules/interactive-functions.js +87 -0
  194. package/linter/rules/process-state-in-session.js +1 -1
  195. package/linter/rules/undefined-symbol-util.d.ts +1 -1
  196. package/linter/rules/undefined-symbol-util.js +8 -2
  197. package/linter/rules/undefined-symbol.js +18 -7
  198. package/linter/rules/useless-loop.d.ts +1 -1
  199. package/package.json +1 -1
  200. package/project/context/flowr-analyzer-dependencies-context.js +2 -1
  201. package/project/flowr-analyzer.d.ts +1 -0
  202. package/project/flowr-analyzer.js +5 -5
  203. package/project/sigdb/build.js +14 -4
  204. package/project/sigdb/decode.d.ts +3 -0
  205. package/project/sigdb/decode.js +10 -1
  206. package/project/sigdb/guarded-source.d.ts +6 -0
  207. package/project/sigdb/guarded-source.js +29 -0
  208. package/project/sigdb/reader.d.ts +5 -0
  209. package/project/sigdb/reader.js +27 -1
  210. package/project/sigdb/schema.d.ts +24 -2
  211. package/queries/catalog/absint-query/absint-query-format.d.ts +6 -3
  212. package/queries/catalog/absint-query/absint-query-format.js +57 -2
  213. package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +6 -2
  214. package/queries/catalog/ambient-access-query/ambient-access-query-format.js +48 -3
  215. package/queries/catalog/cluster-query/cluster-query-format.d.ts +5 -2
  216. package/queries/catalog/cluster-query/cluster-query-format.js +19 -2
  217. package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +5 -2
  218. package/queries/catalog/code-clones-query/code-clones-query-format.js +34 -2
  219. package/queries/catalog/config-query/config-query-format.d.ts +5 -2
  220. package/queries/catalog/config-query/config-query-format.js +41 -2
  221. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +5 -2
  222. package/queries/catalog/control-flow-query/control-flow-query-format.js +19 -2
  223. package/queries/catalog/data-columns-query/data-columns-query-format.d.ts +72 -0
  224. package/queries/catalog/data-columns-query/data-columns-query-format.js +215 -0
  225. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +5 -2
  226. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +38 -2
  227. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +5 -2
  228. package/queries/catalog/dataflow-query/dataflow-query-format.js +18 -2
  229. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  230. package/queries/catalog/dependencies-query/dependencies-query-format.js +8 -3
  231. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +1 -1
  232. package/queries/catalog/dependencies-query/function-info/tagged-functions.d.ts +11 -0
  233. package/queries/catalog/dependencies-query/function-info/tagged-functions.js +18 -0
  234. package/queries/catalog/dice-query/dice-query-format.d.ts +7 -2
  235. package/queries/catalog/dice-query/dice-query-format.js +34 -2
  236. package/queries/catalog/does-call-query/does-call-query-format.d.ts +7 -4
  237. package/queries/catalog/does-call-query/does-call-query-format.js +114 -2
  238. package/queries/catalog/files-query/files-query-format.d.ts +5 -2
  239. package/queries/catalog/files-query/files-query-format.js +45 -2
  240. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +6 -3
  241. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +303 -2
  242. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +8 -4
  243. package/queries/catalog/happens-before-query/happens-before-query-format.js +37 -2
  244. package/queries/catalog/id-map-query/id-map-query-format.d.ts +5 -2
  245. package/queries/catalog/id-map-query/id-map-query-format.js +18 -2
  246. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +5 -2
  247. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +29 -2
  248. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +37 -0
  249. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +125 -0
  250. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -2
  251. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +54 -2
  252. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -2
  253. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +23 -2
  254. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -2
  255. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +15 -2
  256. package/queries/catalog/linter-query/linter-query-format.d.ts +8 -2
  257. package/queries/catalog/linter-query/linter-query-format.js +69 -4
  258. package/queries/catalog/location-map-query/location-map-query-format.d.ts +7 -3
  259. package/queries/catalog/location-map-query/location-map-query-format.js +70 -2
  260. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +5 -2
  261. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +18 -2
  262. package/queries/catalog/origin-query/origin-query-format.d.ts +6 -3
  263. package/queries/catalog/origin-query/origin-query-format.js +29 -2
  264. package/queries/catalog/project-query/project-query-format.d.ts +6 -3
  265. package/queries/catalog/project-query/project-query-format.js +98 -2
  266. package/queries/catalog/provenance-query/provenance-query-format.d.ts +6 -3
  267. package/queries/catalog/provenance-query/provenance-query-format.js +30 -2
  268. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +9 -2
  269. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +38 -2
  270. package/queries/catalog/search-query/search-query-format.d.ts +5 -2
  271. package/queries/catalog/search-query/search-query-format.js +23 -2
  272. package/queries/catalog/signature-query/signature-query-executor.js +3 -1
  273. package/queries/catalog/signature-query/signature-query-format.d.ts +3 -0
  274. package/queries/catalog/signature-query/signature-query-render.js +23 -0
  275. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +13 -2
  276. package/queries/catalog/static-slice-query/static-slice-query-format.js +55 -2
  277. package/queries/catalog/taint-query/taint-query-format.d.ts +6 -3
  278. package/queries/catalog/taint-query/taint-query-format.js +28 -2
  279. package/queries/query.d.ts +48 -27
  280. package/queries/query.js +6 -4
  281. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +2 -0
  282. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -0
  283. package/r-bridge/shell.js +7 -2
  284. package/reconstruct/reconstruct.js +18 -3
  285. package/slicing/static/removal-slice.js +4 -3
  286. package/slicing/static/slice-call.d.ts +11 -0
  287. package/slicing/static/slice-call.js +43 -2
  288. package/slicing/static/static-slicer.d.ts +2 -0
  289. package/slicing/static/static-slicer.js +137 -21
  290. package/slicing/static/visiting-queue.d.ts +2 -0
  291. package/slicing/static/visiting-queue.js +4 -0
  292. package/util/flowr-version.d.ts +1 -1
  293. package/util/flowr-version.js +2 -2
  294. package/util/objects.d.ts +2 -0
  295. package/util/objects.js +5 -0
  296. package/util/r-datasets.d.ts +27 -0
  297. package/util/r-datasets.js +45 -0
  298. package/util/text/playground-link.d.ts +2 -0
  299. package/util/text/playground-link.js +2 -0
  300. package/queries/catalog/absint-query/absint-query-executor.d.ts +0 -6
  301. package/queries/catalog/absint-query/absint-query-executor.js +0 -61
  302. package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +0 -6
  303. package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +0 -50
  304. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +0 -6
  305. package/queries/catalog/cluster-query/cluster-query-executor.js +0 -21
  306. package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +0 -6
  307. package/queries/catalog/code-clones-query/code-clones-query-executor.js +0 -38
  308. package/queries/catalog/config-query/config-query-executor.d.ts +0 -6
  309. package/queries/catalog/config-query/config-query-executor.js +0 -45
  310. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +0 -6
  311. package/queries/catalog/control-flow-query/control-flow-query-executor.js +0 -21
  312. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +0 -6
  313. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +0 -40
  314. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +0 -6
  315. package/queries/catalog/dataflow-query/dataflow-query-executor.js +0 -20
  316. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +0 -9
  317. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +0 -18
  318. package/queries/catalog/dice-query/dice-query-executor.d.ts +0 -8
  319. package/queries/catalog/dice-query/dice-query-executor.js +0 -37
  320. package/queries/catalog/does-call-query/does-call-query-executor.d.ts +0 -6
  321. package/queries/catalog/does-call-query/does-call-query-executor.js +0 -116
  322. package/queries/catalog/files-query/files-query-executor.d.ts +0 -6
  323. package/queries/catalog/files-query/files-query-executor.js +0 -47
  324. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +0 -6
  325. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +0 -307
  326. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +0 -7
  327. package/queries/catalog/happens-before-query/happens-before-query-executor.js +0 -40
  328. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +0 -6
  329. package/queries/catalog/id-map-query/id-map-query-executor.js +0 -20
  330. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -6
  331. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +0 -31
  332. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +0 -4
  333. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +0 -58
  334. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +0 -7
  335. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +0 -25
  336. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +0 -7
  337. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +0 -17
  338. package/queries/catalog/linter-query/linter-query-executor.d.ts +0 -9
  339. package/queries/catalog/linter-query/linter-query-executor.js +0 -62
  340. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +0 -7
  341. package/queries/catalog/location-map-query/location-map-query-executor.js +0 -73
  342. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +0 -6
  343. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +0 -20
  344. package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -6
  345. package/queries/catalog/origin-query/origin-query-executor.js +0 -31
  346. package/queries/catalog/project-query/project-query-executor.d.ts +0 -6
  347. package/queries/catalog/project-query/project-query-executor.js +0 -103
  348. package/queries/catalog/provenance-query/provenance-query-executor.d.ts +0 -6
  349. package/queries/catalog/provenance-query/provenance-query-executor.js +0 -33
  350. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +0 -10
  351. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +0 -40
  352. package/queries/catalog/search-query/search-query-executor.d.ts +0 -6
  353. package/queries/catalog/search-query/search-query-executor.js +0 -25
  354. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +0 -14
  355. package/queries/catalog/static-slice-query/static-slice-query-executor.js +0 -59
  356. package/queries/catalog/taint-query/taint-query-executor.d.ts +0 -7
  357. package/queries/catalog/taint-query/taint-query-executor.js +0 -30
@@ -4,6 +4,7 @@ exports.processFunctionDefinition = processFunctionDefinition;
4
4
  exports.retrieveActiveEnvironment = retrieveActiveEnvironment;
5
5
  exports.updateNestedFunctionClosures = updateNestedFunctionClosures;
6
6
  exports.callBoundInScope = callBoundInScope;
7
+ exports.nameReadsOf = nameReadsOf;
7
8
  exports.updateNestedFunctionCalls = updateNestedFunctionCalls;
8
9
  const processor_1 = require("../../../../../processor");
9
10
  const function_semantics_1 = require("../../../../../fn/function-semantics");
@@ -48,6 +49,8 @@ const query_fn_props_1 = require("../../../../../environments/query-fn-props");
48
49
  const built_in_props_1 = require("../../../../../environments/built-in-props");
49
50
  const arrays_1 = require("../../../../../../util/collections/arrays");
50
51
  const group_generics_1 = require("../../../../../environments/group-generics");
52
+ const default_builtin_config_1 = require("../../../../../environments/default-builtin-config");
53
+ const r_primitives_generated_1 = require("../../../../../../data/r-primitives.generated");
51
54
  const arg_matching_1 = require("../../../../../../util/arg-matching");
52
55
  const defaultmap_1 = require("../../../../../../util/collections/defaultmap");
53
56
  const df_helper_1 = require("../../../../../graph/df-helper");
@@ -182,6 +185,12 @@ function processFunctionDefinition(name, args, rootId, data) {
182
185
  subgraph.addEdge(rootId, hook.id, edge_1.EdgeType.Calls);
183
186
  const hookExitPoints = vert.exitPoints.filter(e => e.type === 1 /* ExitPointType.Return */ || e.type === 4 /* ExitPointType.Error */);
184
187
  if (hookExitPoints.length > 0) {
188
+ /* R prints the message of an error before the hook runs, so what the hook hands back instead still shows it */
189
+ for (const raised of afterHookExitPoints.filter(e => e.type === 4 /* ExitPointType.Error */)) {
190
+ for (const exit of hookExitPoints) {
191
+ subgraph.addEdge(exit.nodeId, raised.nodeId, edge_1.EdgeType.Reads);
192
+ }
193
+ }
185
194
  afterHookExitPoints = (0, info_1.overwriteExitPoints)(afterHookExitPoints, hookExitPoints);
186
195
  }
187
196
  }
@@ -255,10 +264,28 @@ function envStateReturnedAt(nodeId, graph, outEnvironment, data) {
255
264
  return undefined;
256
265
  }
257
266
  const environment = { environment: outEnvironment };
267
+ if (isOwnFrame(node, graph, outEnvironment)) {
268
+ return outEnvironment;
269
+ }
258
270
  return (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.List) ? (0, built_in_list_1.resolveListToEnvState)(node, environment) : undefined)
259
271
  ?? (vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.ClassGenerator) ? (0, built_in_class_generator_1.resolveClassMethodsToEnvState)(node, environment) : undefined)
260
272
  ?? (r_symbol_1.RSymbol.is(node) ? resolve_helper_1.Resolve.byNameAndType(node.content, outEnvironment, identifier_1.ReferenceType.Variable)?.find(identifier_1.hasEnvState)?.envState : undefined);
261
273
  }
274
+ /** Whether `node` is the frame of the function being defined: a call of `environment()` or a variable of that frame bound to one (`self <- environment()`), the frame then holds everything the body bound by the time it returns. */
275
+ function isOwnFrame(node, graph, outEnvironment) {
276
+ const isEnvironmentCall = (n) => {
277
+ const vertex = n === undefined ? undefined : graph.getVertex(n.info.id);
278
+ return r_function_call_1.RFunctionCall.isNamed(n, 'environment') && n.arguments.length === 0 && vertex_1.DfgVertex.isFunctionCall(vertex) && vertex.onlyBuiltin;
279
+ };
280
+ if (isEnvironmentCall(node)) {
281
+ return true;
282
+ }
283
+ if (!r_symbol_1.RSymbol.is(node)) {
284
+ return false;
285
+ }
286
+ const defs = outEnvironment.current.memory.get(identifier_1.Identifier.getName(node.content));
287
+ return defs !== undefined && defs.length > 0 && defs.every(d => d.value?.some(v => isEnvironmentCall(graph.idMap?.get(v))) === true);
288
+ }
262
289
  /** Retrieve the active environment when entering a function definition or call. */
263
290
  function retrieveActiveEnvironment(callerEnvironment, baseEnvironment, ctx) {
264
291
  callerEnvironment ??= ctx.env.makeCleanEnv();
@@ -363,7 +390,16 @@ function updateNestedFunctionClosures(graph, outEnvironment, openReads) {
363
390
  }
364
391
  /** Whether an enclosing scope binds the name of a call within a closure before the closure exists, see {@link boundBeforeClosure}: then the call reaches only what its reads do, and never looks further out, whatever the end of the script binds there. */
365
392
  function callBoundInScope(call, graph) {
366
- return !graph.isRoot(call) && df_helper_1.Dataflow.targetsOf(graph, call, edge_1.EdgeType.Reads).some(r => boundBeforeClosure(r, call, graph));
393
+ return !graph.isRoot(call) && nameReadsOf(call, graph).some(r => boundBeforeClosure(r, call, graph));
394
+ }
395
+ /**
396
+ * The definitions the name of `call` reads, without what else it reads: the methods a built-in runs (`[.cls` for `x[i]`)
397
+ * and what they return, which say nothing about what the name is bound to.
398
+ */
399
+ function nameReadsOf(call, graph) {
400
+ const vertex = graph.getVertex(call);
401
+ const name = vertex_1.DfgVertex.isFunctionCall(vertex) && vertex.name !== undefined ? String(identifier_1.Identifier.getName(vertex.name)) : undefined;
402
+ return df_helper_1.Dataflow.targetsOf(graph, call, edge_1.EdgeType.Reads).filter(r => name === undefined || node_id_1.NodeId.recoverBareName(r, graph.idMap) === name);
367
403
  }
368
404
  /** Whether the local definition `def` is made before the closure holding the read `read` is created, on every way there: `h <- function() 2; g <- function() h()` binds `h` in the scope before `g` exists, so no call of `g` looks past the scope for it. */
369
405
  function boundBeforeClosure(def, read, graph) {
@@ -437,7 +473,7 @@ function dispatchesOnClass(name, environment, infoOf) {
437
473
  }
438
474
  /** Links `call` to the S3 methods the analyzed code binds as `<name>.<class>`, returning their definition vertices and the dispatched objects. */
439
475
  function linkOwnS3Methods(call, name, graph, environment, statement, ctx, infoOf) {
440
- const defs = s3MethodPrefixesOf(name).flatMap(prefix => resolve_helper_1.Resolve.byNameAndType(prefix, environment, identifier_1.ReferenceType.S3MethodPrefix) ?? [])
476
+ const defs = (0, group_generics_1.s3MethodPrefixesOf)(name).flatMap(prefix => resolve_helper_1.Resolve.byNameAndType(prefix, environment, identifier_1.ReferenceType.S3MethodPrefix) ?? [])
441
477
  .filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId) && !program_order_1.ProgramOrder.definedLater(d.nodeId, statement, graph));
442
478
  if (defs.length === 0) {
443
479
  return { methods: [] };
@@ -450,12 +486,6 @@ function linkOwnS3Methods(call, name, graph, environment, statement, ctx, infoOf
450
486
  }
451
487
  return { methods: (0, dispatch_linking_1.linkedFunctionIds)(new Set(chosen.map(d => d.nodeId)), graph), objects: dispatched?.objects };
452
488
  }
453
- /** The names whose `<name>.<class>` methods a call of `name` may dispatch to: its own and that of the S3 group generic it is a member of. */
454
- function s3MethodPrefixesOf(name) {
455
- const plain = identifier_1.Identifier.getName(name);
456
- const group = (0, group_generics_1.s3GroupGenericOf)(plain);
457
- return group === undefined ? [plain] : [plain, group];
458
- }
459
489
  /** The arguments the S3 dispatch of a call of a built-in generic looks at the class of, `undefined` if they are not clear. */
460
490
  function dispatchedArgumentsOf(call, node, name, graph, environment, ctx, infoOf) {
461
491
  const args = call.args.filter(a => a !== r_function_call_1.EmptyArgument);
@@ -493,7 +523,7 @@ function dispatchedS3Methods(call, name, methods, graph, environment, statement,
493
523
  return { objects: dispatched };
494
524
  }
495
525
  const classes = perArgument.flat();
496
- const prefixes = s3MethodPrefixesOf(name);
526
+ const prefixes = (0, group_generics_1.s3MethodPrefixesOf)(name);
497
527
  const pick = (stopAt) => {
498
528
  const picked = new Set();
499
529
  for (const cls of classes) {
@@ -545,7 +575,7 @@ function dispatchedObjectOf(vertex, graph) {
545
575
  /** What the dispatch of `vertex` among `targets` rules out, S3 on the objects `s3Objects` and S4 on the classes of its arguments. */
546
576
  function narrowedDispatchOf(narrower, vertex, s3Objects, targets, definedLater, info) {
547
577
  const name = identifier_1.Identifier.getName(vertex.name);
548
- const s3 = s3Objects === undefined ? undefined : narrower.s3(s3Objects, s3MethodPrefixesOf(vertex.name), targets, info);
578
+ const s3 = s3Objects === undefined ? undefined : narrower.s3(s3Objects, (0, group_generics_1.s3MethodPrefixesOf)(vertex.name), targets, info);
549
579
  const s4 = narrower.reachesS4Method(targets) ? narrower.s4(vertex, name, targets, definedLater, info) : undefined;
550
580
  if (s3 === undefined || s4 === undefined) {
551
581
  return s3 ?? s4;
@@ -617,11 +647,44 @@ function nextMethodsPerCall(next, owner, dispatch, contexts, collected, graph) {
617
647
  .map(([n, m]) => ({ call: n, methods: [], within: runsOf(m, new Set([...seen, m])) }))];
618
648
  return within === undefined ? undefined : runsOf(owner, new Set([owner]));
619
649
  }
650
+ /** the processors of calls that run their R code as it is, handing on what they get */
651
+ const RunsPlainCode = new Set([built_in_proc_name_1.BuiltInProcName.Default, built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, built_in_proc_name_1.BuiltInProcName.Apply]);
652
+ /** The internal generics and the S3 groups, which R code may dispatch to on whatever it is handed, without naming them as a call the signature database records (`x[i]`). */
653
+ const DispatchedInternally = [...default_builtin_config_1.InternalGenerics, ...group_generics_1.S3Groups];
654
+ /** Whether the `call` may hand on an object a method may get: a constant (`structure(1, class = "a")`) has no class. */
655
+ function handsObjects(call, idMap) {
656
+ return call.args.some(a => a !== r_function_call_1.EmptyArgument && !model_1.RConstant.is(r_argument_1.RArgument.valueOf(idMap?.get(a.nodeId))));
657
+ }
658
+ /**
659
+ * The generics a call of the built-in `name` may run on what it is handed besides its own: those the configuration states
660
+ * (`nrow(x)` asks `dim(x)`), else for a function of R code (`median`, `head`) every internal one as well as those its code
661
+ * calls (as the signature database knows), also through the default method of a generic it calls.
662
+ */
663
+ function genericsRunWithin(name, ctx) {
664
+ const builtIn = ctx.env.builtInFunctionOf(name);
665
+ const stated = builtIn?.config?.dispatches;
666
+ const called = calleesOf(name, ctx)?.filter(c => default_builtin_config_1.RGenerics.has(c));
667
+ /* what the configuration states it dispatches to is all, a processor of its own models what the call does (`setMethod`), a primitive runs no R code, and a name flowR knows nothing of is no built-in */
668
+ if (stated !== undefined || (builtIn !== undefined && !RunsPlainCode.has(builtIn.processorName)) || r_primitives_generated_1.RPrimitives.has(String(identifier_1.Identifier.getName(name))) || (called === undefined && builtIn === undefined)) {
669
+ return stated ?? [];
670
+ }
671
+ const generic = default_builtin_config_1.RGenerics.has(identifier_1.Identifier.getName(name)) ? [identifier_1.Identifier.getName(name)] : [];
672
+ const viaDefaults = [...generic, ...called ?? []].flatMap(g => calleesOf(identifier_1.Identifier.make(`${g}.default`), ctx)?.filter(c => default_builtin_config_1.RGenerics.has(c)) ?? []);
673
+ return (0, arrays_1.uniqueArray)([...DispatchedInternally, ...called ?? [], ...viaDefaults].map(String));
674
+ }
675
+ /** What the R code of the package function `name` calls, `undefined` if the signature database knows no code for it. */
676
+ function calleesOf(name, ctx) {
677
+ return (0, query_fn_props_1.fnEntry)(name, ctx).entry?.callees;
678
+ }
620
679
  /**
621
680
  * Update the closure links of all nested function calls, done once at the end of the script.
622
681
  * @lintIgnore vertex-has-origin
623
682
  */
624
683
  function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
684
+ /* linking changes the graph after nearly every call it resolves, so the walks are not worth sharing */
685
+ graph.withoutSharedTargetWalks(() => linkNestedFunctionCalls(graph, outEnvironment, ctx));
686
+ }
687
+ function linkNestedFunctionCalls(graph, outEnvironment, ctx) {
625
688
  const { shadowing, generics } = namesShadowingBuiltIns(outEnvironment, graph);
626
689
  let rootDefinitions;
627
690
  const calls = graph.verticesOfType(vertex_1.VertexType.FunctionCall).toArray();
@@ -634,12 +697,18 @@ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
634
697
  const runsOnceAt = (0, defaultmap_1.memoize)((id) => program_order_1.ProgramOrder.runsOnceAt(id, graph));
635
698
  const databaseInfoOf = (0, defaultmap_1.memoize)((name) => ctx.functionInfo(name));
636
699
  /* the generics a built-in dispatches to on its own whose methods the code binds */
637
- const internalOf = (0, defaultmap_1.memoize)((name) => ctx.env.builtInFunctionOf(name)?.config?.dispatches?.filter(g => generics.has(g) || shadowing.has(g)) ?? []);
700
+ const runWithin = (0, defaultmap_1.memoize)((name) => genericsRunWithin(name, ctx));
701
+ const internalOf = (0, defaultmap_1.memoize)((name) => generics.size === 0 && shadowing.size === 0 ? [] : runWithin(name).filter(g => generics.has(g) || shadowing.has(g)));
638
702
  const environmentAt = (0, defaultmap_1.memoize)((id) => {
639
703
  const environment = graph.getVertex(id).environment;
640
704
  return environment ? environment_1.REnvironment.overwrite(outEnvironment, environment) : outEnvironment;
641
705
  });
642
706
  const narrower = new dispatch_linking_1.DispatchNarrower(graph, ctx);
707
+ /* the bindings of names we cannot tell that run, i.e. those at the top or in a function the code calls */
708
+ const unknownMethodsAt = (environment_1.REnvironment.findBuiltIn(outEnvironment.current).unknownMethodsAt ?? []).filter(at => {
709
+ const fn = enclosingOf(at);
710
+ return fn === undefined || graph.edgesTo(fn).values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Calls));
711
+ });
643
712
  /* per function, the `NextMethod` calls of its body */
644
713
  const namedNextCalls = new Map();
645
714
  for (const [id, vertex] of calls) {
@@ -684,11 +753,15 @@ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
684
753
  }
685
754
  continue;
686
755
  }
756
+ /* a method the code binds by a name we cannot tell may be one the call dispatches to */
757
+ if (unknownMethodsAt.some(at => !program_order_1.ProgramOrder.definedLater(at, runsOnceAt(id), graph)) && ((handsObjects(vertex, graph.idMap) && runWithin(name).length > 0) || dispatchesOnClass(name, environmentAt(id), databaseInfoOf))) {
758
+ graph.markIdForUnknownSideEffects(id);
759
+ }
687
760
  /* the code writes a `<name>.<class>`, so a built-in `name` that dispatches may reach it */
688
- const mayDispatch = s3MethodPrefixesOf(name).some(p => generics.has(p));
761
+ const mayDispatch = (0, group_generics_1.s3MethodPrefixesOf)(name).some(p => generics.has(p));
689
762
  /* a `setMethod("Arith", ...)` claims every member of the S4 group, so a built-in member may reach its methods */
690
763
  const s4Groups = (0, group_generics_1.s4GroupGenericsOf)(identifier_1.Identifier.getName(name)).filter(g => shadowing.has(g));
691
- const internal = internalOf(name);
764
+ const internal = handsObjects(vertex, graph.idMap) ? internalOf(name) : [];
692
765
  if (onlyBuiltin && !mayDispatch && s4Groups.length === 0 && internal.length === 0 && !(!graph.isRoot(id) && shadowing.has(identifier_1.Identifier.getName(name)))) {
693
766
  continue;
694
767
  }
@@ -698,7 +771,7 @@ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
698
771
  /* the dispatch is decided anew, from every method the name may reach */
699
772
  delete vertex.ruledOut;
700
773
  delete vertex.ruledOutAt;
701
- const targets = new Set(callBoundInScope(id, graph) ? (0, dispatch_linking_1.linkedFunctionIds)(new Set(df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads)), graph) : df_helper_1.Dataflow.callTargetsOf(id, graph, effectiveEnvironment));
774
+ const targets = new Set(callBoundInScope(id, graph) ? (0, dispatch_linking_1.linkedFunctionIds)(new Set(nameReadsOf(id, graph)), graph) : df_helper_1.Dataflow.callTargetsOf(id, graph, effectiveEnvironment));
702
775
  /* a dispatch depends on the classes of its arguments, so it waits for the value flow to be linked */
703
776
  const dispatches = origin.includes(built_in_proc_name_1.BuiltInProcName.S3Dispatch) || narrower.reachesS4Method(targets) || mayDispatch && dispatchesOnClass(name, effectiveEnvironment, databaseInfoOf);
704
777
  if (dispatches && !deferred.has(id)) {
@@ -747,7 +820,14 @@ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
747
820
  }
748
821
  for (const method of internal.length === 0 ? [] : (0, dispatch_linking_1.internalGenericMethods)(internal, methodEnvironment(), graph).filter(m => !definedLater(m.nodeId))) {
749
822
  graph.addEdge(id, method.nodeId, edge_1.EdgeType.Reads);
750
- (0, dispatch_linking_1.linkedFunctionIds)(new Set([method.nodeId]), graph).forEach(t => targets.add(t));
823
+ for (const target of (0, dispatch_linking_1.linkedFunctionIds)(new Set([method.nodeId]), graph)) {
824
+ targets.add(target);
825
+ /* the built-in goes on with what the method returns (`message(cnd)` prints what `conditionMessage` gives) */
826
+ const fn = graph.getVertex(target);
827
+ for (const exit of vertex_1.DfgVertex.isFunctionDefinition(fn) ? fn.exitPoints : []) {
828
+ graph.addEdge(id, exit.nodeId, edge_1.EdgeType.Reads);
829
+ }
830
+ }
751
831
  }
752
832
  const decide = (info) => {
753
833
  const decided = narrowedDispatchOf(narrower, vertex, s3Objects, targets, definedLater, info);
@@ -983,6 +1063,20 @@ function namesRemovedBy(call, idMap) {
983
1063
  }
984
1064
  return names;
985
1065
  }
1066
+ /**
1067
+ * What a frame holds for a `<<-` within a function written in it: what it binds itself, and, as the emptied stand-in of a function around it,
1068
+ * what the frame it stands in for held, so `<<-` in a function three levels deep still finds the binding of the outermost one.
1069
+ */
1070
+ function lexicalMemoryOf(frame) {
1071
+ const original = frame.superMemory;
1072
+ if (original === undefined || original.size === 0) {
1073
+ return frame.memory;
1074
+ }
1075
+ else if (frame.memory.size === 0) {
1076
+ return original;
1077
+ }
1078
+ return new Map([...original, ...frame.memory]);
1079
+ }
986
1080
  function prepareFunctionEnvironment(data, rootId) {
987
1081
  const level = data.environment.level;
988
1082
  /* the enclosing frames are emptied, but a `<<-` binds lexically, so each stand-in keeps what its original held */
@@ -999,7 +1093,7 @@ function prepareFunctionEnvironment(data, rootId) {
999
1093
  env.current.setClosureNodeId(rootId);
1000
1094
  }
1001
1095
  else {
1002
- env.current.standsInFor(enclosing[level - 1 - i].memory);
1096
+ env.current.standsInFor(lexicalMemoryOf(enclosing[level - 1 - i]));
1003
1097
  }
1004
1098
  }
1005
1099
  return { ...data, environment: env };
@@ -23,5 +23,7 @@ export declare function lexicalDefinitions(name: BrandedIdentifier, call: Datafl
23
23
  /** Processes a built-in 'get' function call. */
24
24
  export declare function processGet<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
25
25
  returnsValue?: boolean;
26
+ hasUnknownSideEffects?: boolean;
27
+ locks?: boolean;
26
28
  sig?: FnSig;
27
29
  }): DataflowInformation;
@@ -27,6 +27,7 @@ const assert_1 = require("../../../../../../util/assert");
27
27
  const built_in_props_1 = require("../../../../../environments/built-in-props");
28
28
  const df_helper_1 = require("../../../../../graph/df-helper");
29
29
  const linker_1 = require("../../../../linker");
30
+ const built_in_ambient_state_1 = require("./built-in-ambient-state");
30
31
  function namesDenotedBy(node, data) {
31
32
  const folded = (0, built_in_envir_utils_1.resolveConstantString)(node, data);
32
33
  return folded === undefined ? node_value_1.NodeValue.stringsOf(node.info.id, data) ?? [] : [folded];
@@ -115,7 +116,7 @@ function lexicalDefinitions(name, call, graph) {
115
116
  }
116
117
  let level = 0;
117
118
  for (let frame = call.environment?.current; frame !== undefined && !frame.builtInEnv && frame.globalEnv !== true; frame = frame.parent) {
118
- const found = [...frame.lookup(name) ?? frame.superMemory?.get(name) ?? [], ...level > 0 ? left[level - 1]?.lookup(name) ?? [] : []];
119
+ const found = [...frame.boundForSuper(name) ?? [], ...level > 0 ? left[level - 1]?.lookup(name) ?? [] : []];
119
120
  definitions.push(...found);
120
121
  if (found.some(d => d.cds === undefined)) {
121
122
  return { definitions, definite: true };
@@ -126,7 +127,10 @@ function lexicalDefinitions(name, call, graph) {
126
127
  }
127
128
  /** Processes a built-in 'get' function call. */
128
129
  function processGet(name, args, rootId, data, config = {}) {
129
- const resolution = (0, built_in_envir_utils_1.resolveFirstEnvirArg)(args, data, config.sig, ['envir', ...built_in_envir_utils_1.EnvirPositionFormals]);
130
+ const resolution = (0, built_in_envir_utils_1.resolveFirstEnvirArg)(args, data, config.sig, ['envir', 'env', ...built_in_envir_utils_1.EnvirPositionFormals]);
131
+ if (config.locks) {
132
+ (0, built_in_ambient_state_1.markLocking)(data.environment);
133
+ }
130
134
  const retrieve = r_argument_1.RArgument.unnamedValueOf(args[0]);
131
135
  const targets = retrieve === undefined ? [] : synthesizeTargets(retrieve, name, rootId, data);
132
136
  if (targets.length === 0) {
@@ -177,6 +181,9 @@ function processGet(name, args, rootId, data, config = {}) {
177
181
  else if ((0, built_in_envir_utils_1.suppliesArg)(args, config.sig, built_in_envir_utils_1.EnvirPositionFormals)) {
178
182
  (0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
179
183
  }
184
+ if (config.hasUnknownSideEffects) {
185
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
186
+ }
180
187
  const isolatedTarget = resolution?.envirData.environment.current.builtInEnv === true;
181
188
  const readsToDrop = isolatedTarget
182
189
  ? new Set(named.filter(assert_1.isNotUndefined).map(t => t.entryPoint))
@@ -1,5 +1,5 @@
1
1
  import { type DataflowProcessorInformation } from '../../../../../processor';
2
- import type { DataflowInformation } from '../../../../../info';
2
+ import { type DataflowInformation } from '../../../../../info';
3
3
  import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
4
4
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
5
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
@@ -4,6 +4,7 @@ exports.processIfThenElse = processIfThenElse;
4
4
  const hooks_1 = require("../../../../../hooks");
5
5
  const processor_1 = require("../../../../../processor");
6
6
  const function_semantics_1 = require("../../../../../fn/function-semantics");
7
+ const info_1 = require("../../../../../info");
7
8
  const resolve_1 = require("../../../../../eval/resolve/resolve");
8
9
  const known_call_handling_1 = require("../known-call-handling");
9
10
  const common_1 = require("../common");
@@ -116,8 +117,9 @@ function processIfThenElse(name, args, rootId, data, config) {
116
117
  });
117
118
  // as an if always evaluates its condition, we add a 'reads'-edge
118
119
  nextGraph.addEdge(rootId, cond.entryPoint, edge_1.EdgeType.Reads);
119
- const exitPoints = (then?.exitPoints ?? []).map(e => ({ ...e, cds: uncertain ? [...data.cds ?? [], { id: rootId, when: true }] : e.cds }))
120
- .concat((otherwise?.exitPoints ?? []).map(e => ({ ...e, cds: uncertain ? [...data.cds ?? [], { id: rootId, when: false }] : e.cds })));
120
+ /* a branch's exit keeps the conditions it has within the branch, as the `return` of an `else if` without an `else` (#2810) */
121
+ const underBranch = (exits, when) => (exits ?? []).map(e => ({ ...e, cds: uncertain ? (0, info_1.withCds)(e.cds ?? data.cds, [{ id: rootId, when }]) : e.cds }));
122
+ const exitPoints = underBranch(then?.exitPoints, true).concat(underBranch(otherwise?.exitPoints, false));
121
123
  const entryOrJoin = (branch) => branch ? control_flow_1.ControlFlow.entryOf(branch) : rootId;
122
124
  const reachesJoin = then === undefined || otherwise === undefined
123
125
  || control_flow_1.ControlFlow.canComplete(then) || control_flow_1.ControlFlow.canComplete(otherwise);
@@ -60,6 +60,11 @@ export declare function attachLibrary(pack: BrandedNamespace, dependency: Packag
60
60
  * global environment. A call nothing resolves may go to any of them.
61
61
  */
62
62
  export declare function loadNodesForNamespace(env: REnvironmentInformation, pack?: BrandedNamespace): NodeId[];
63
+ /**
64
+ * The load calls that attached a package shipping the data set `name` (`starwars` of `dplyr`), which a read of the
65
+ * name that nothing defines has to keep: R finds the data set as lazy data of the attached package.
66
+ */
67
+ export declare function dataLoadNodesForNamespace(env: REnvironmentInformation, name: BrandedIdentifier): NodeId[];
63
68
  /**
64
69
  * Processes `conflicted::conflict_prefer(name, winner)` and `conflicts_prefer(pkg::fn, ...)`: the preferred function is
65
70
  * put on top of the search path, as conflicted does with its `.conflicts` entry, so the name resolves to it from then on.
@@ -4,6 +4,7 @@ exports.processLibrary = processLibrary;
4
4
  exports.attachExportVertex = attachExportVertex;
5
5
  exports.attachLibrary = attachLibrary;
6
6
  exports.loadNodesForNamespace = loadNodesForNamespace;
7
+ exports.dataLoadNodesForNamespace = dataLoadNodesForNamespace;
7
8
  exports.processPrefer = processPrefer;
8
9
  exports.attachDependencyToEnvironment = attachDependencyToEnvironment;
9
10
  exports.attachBaseRNamespaces = attachBaseRNamespaces;
@@ -42,6 +43,7 @@ const vertex_1 = require("../../../../../graph/vertex");
42
43
  const r_base_packages_1 = require("../../../../../../util/r-base-packages");
43
44
  const built_in_envir_utils_1 = require("./built-in-envir-utils");
44
45
  const arrays_1 = require("../../../../../../util/collections/arrays");
46
+ const r_datasets_1 = require("../../../../../../util/r-datasets");
45
47
  const built_in_load_1 = require("./built-in-load");
46
48
  /**
47
49
  * Process a library call like `library` or `require`
@@ -332,6 +334,26 @@ function loadNodesForNamespace(env, pack) {
332
334
  }
333
335
  return nodes;
334
336
  }
337
+ /**
338
+ * The load calls that attached a package shipping the data set `name` (`starwars` of `dplyr`), which a read of the
339
+ * name that nothing defines has to keep: R finds the data set as lazy data of the attached package.
340
+ */
341
+ function dataLoadNodesForNamespace(env, name) {
342
+ if (env.current.builtInEnv) {
343
+ return [];
344
+ }
345
+ const loads = new Map();
346
+ for (const e of environment_1.REnvironment.searchPath(env.current)) {
347
+ if (e.t === undefined) {
348
+ break;
349
+ }
350
+ if (e.n !== undefined && e.d !== undefined) {
351
+ loads.set(e.n, [...loads.get(e.n) ?? [], e.d]);
352
+ }
353
+ }
354
+ const pkg = loads.size === 0 ? undefined : (0, r_datasets_1.datasetShape)(name, undefined, p => loads.has(p))?.pkg;
355
+ return pkg === undefined ? [] : loads.get(pkg) ?? [];
356
+ }
335
357
  /**
336
358
  * Processes `conflicted::conflict_prefer(name, winner)` and `conflicts_prefer(pkg::fn, ...)`: the preferred function is
337
359
  * put on top of the search path, as conflicted does with its `.conflicts` entry, so the name resolves to it from then on.
@@ -438,6 +460,7 @@ function attachResolved(dependency, envInfo, ctx, spec, definedAt, attaching, cd
438
460
  const layerType = spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace;
439
461
  const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, layerType);
440
462
  layer.adoptMap(lazyExports(pack, exports, ctx, definedAt, cds, dependency.namespaceInfo));
463
+ layer.d = shipsData(pack) ? definedAt : undefined;
441
464
  return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, spec.pos) };
442
465
  }
443
466
  /* as R does: the Depends first (at the default position, whatever `pos` says), then `pack`, then what its `.onAttach` attaches */
@@ -450,9 +473,14 @@ function attachResolved(dependency, envInfo, ctx, spec, definedAt, attaching, cd
450
473
  const importsEnv = imports(new environment_1.Environment(below.current).asLibrary(pack, environment_1.EnvType.Imports), dependency.namespaceInfo, ctx);
451
474
  const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace);
452
475
  namespaceEnv.adoptMap(lazyExports(pack, exports, ctx, definedAt, cds, dependency.namespaceInfo));
476
+ namespaceEnv.d = shipsData(pack) ? definedAt : undefined;
453
477
  const attached = { level: below.level, current: environment_1.REnvironment.attachAt(below.current, namespaceEnv, importsEnv, withStartupPosition(pack, below, spec).pos) };
454
478
  return alongside(attached, onAttach);
455
479
  }
480
+ /** whether `pack` ships data sets, which its load binds as lazy data */
481
+ function shipsData(pack) {
482
+ return (0, r_datasets_1.datasetsOf)(pack).length > 0;
483
+ }
456
484
  /** `spec` with the position R gives a startup package, unless a position is given, see {@link startupAttachPosition} */
457
485
  function withStartupPosition(pack, envInfo, spec) {
458
486
  if (spec.pos !== undefined || spec.namespaceOnly) {
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processLoadCall = processLoadCall;
4
4
  exports.sexpTypeToReferenceType = sexpTypeToReferenceType;
5
5
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
6
+ const control_flow_1 = require("../../../../control-flow");
7
+ const built_in_expression_list_1 = require("./built-in-expression-list");
6
8
  const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
7
9
  const resolve_helper_1 = require("../../../../../environments/resolve-helper");
8
10
  const ambient_state_name_1 = require("../../../../../environments/ambient-state-name");
@@ -16,7 +18,6 @@ const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
16
18
  const built_in_source_1 = require("./built-in-source");
17
19
  const vertex_1 = require("../../../../../graph/vertex");
18
20
  const logger_1 = require("../../../../../logger");
19
- const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
20
21
  const edge_1 = require("../../../../../graph/edge");
21
22
  const node_value_1 = require("../../../../../eval/resolve/node-value");
22
23
  const r_value_1 = require("../../../../../eval/values/r-value");
@@ -34,13 +35,13 @@ function processLoadCall(name, args, rootId, data) {
34
35
  const { fileArg, envirArg } = loadArgsOf(args, data);
35
36
  if (!fileArg) {
36
37
  const fn = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' });
37
- (0, unknown_side_effect_1.handleUnknownSideEffect)(fn.information.graph, fn.information.environment, rootId);
38
+ (0, built_in_expression_list_1.bindsUnknownNames)(fn.information.graph, fn.information.environment, rootId);
38
39
  return fn.information;
39
40
  }
40
41
  const fn = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Load });
41
42
  if (data.ctx.config.ignoreLoadCalls) {
42
43
  logger_1.dataflowLogger.warn(`Skipping load call ${JSON.stringify(fileArg)} (disabled in config file)`);
43
- (0, unknown_side_effect_1.handleUnknownSideEffect)(fn.information.graph, fn.information.environment, rootId);
44
+ (0, built_in_expression_list_1.bindsUnknownNames)(fn.information.graph, fn.information.environment, rootId);
44
45
  return fn.information;
45
46
  }
46
47
  const envirResolution = envirArg ? (0, built_in_envir_utils_1.envirOf)((0, built_in_envir_utils_1.resolveArgToEnvirOrAmbiguous)(envirArg, data)) : undefined;
@@ -92,12 +93,12 @@ function processLoadCall(name, args, rootId, data) {
92
93
  if (saved !== undefined) {
93
94
  const loaded = withLoaded(saved.names.map(n => ({ name: n })), rootId, fn, [...(data.cds ?? []), { id: rootId, when: true }], data, envirResolution);
94
95
  if (!saved.complete) {
95
- (0, unknown_side_effect_1.handleUnknownSideEffect)(loaded.graph, loaded.environment, rootId);
96
+ (0, built_in_expression_list_1.bindsUnknownNames)(loaded.graph, loaded.environment, rootId);
96
97
  }
97
98
  return loaded;
98
99
  }
99
100
  }
100
- (0, unknown_side_effect_1.handleUnknownSideEffect)(fn.information.graph, fn.information.environment, rootId);
101
+ (0, built_in_expression_list_1.bindsUnknownNames)(fn.information.graph, fn.information.environment, rootId);
101
102
  return fn.information;
102
103
  }
103
104
  /**
@@ -163,12 +164,21 @@ function withLoaded(variables, rootId, fn, loadCds, data, envir) {
163
164
  const location = data.completeAst.idMap.get(rootId)?.location ?? range_1.SourceRange.invalid();
164
165
  let environment = fn.information.environment;
165
166
  const out = [...fn.information.out];
167
+ /* the restored names are bound once the call completes, one after the other, and the program goes on from the last */
168
+ let flow = fn.information;
166
169
  for (const variable of variables) {
167
170
  const [next, defined] = defineLoadedVariable(variable, rootId, fn, environment, location, loadCds, data);
168
171
  environment = next;
172
+ (0, built_in_expression_list_1.noteOwnMethod)(variable.name, environment, data.ctx);
169
173
  out.push(defined);
174
+ for (const id of [`${defined.nodeId}:fdef`, defined.nodeId]) {
175
+ if (fn.information.graph.hasVertex(id)) {
176
+ control_flow_1.ControlFlow.continuesWith(fn.information.graph, flow, id);
177
+ flow = { ...flow, cfgExit: id };
178
+ }
179
+ }
170
180
  }
171
- const result = { ...fn.information, environment, out };
181
+ const result = { ...fn.information, environment, out, cfgExit: flow.cfgExit };
172
182
  return envir === undefined ? result : (0, built_in_envir_utils_1.routeWrittenToEnvir)(result, envir, rootId, data.environment, rootId);
173
183
  }
174
184
  function defineLoadedVariable(variable, rootId, fn, envir, loadLocation, loadCds, data) {
@@ -1,5 +1,5 @@
1
1
  import type { DataflowProcessorInformation } from '../../../../../processor';
2
- import { DataflowInformation } from '../../../../../info';
2
+ import { DataflowInformation, type ExitPoint } from '../../../../../info';
3
3
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
5
  import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
@@ -20,3 +20,8 @@ export interface LocalFunctionConfiguration {
20
20
  export declare function processLocal<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: LocalFunctionConfiguration): DataflowInformation;
21
21
  /** Evaluates `expr` in the environment `envir` pins down, or in a fresh frame on top of the current one, as `local` and `eval(expr, envir)` do. */
22
22
  export declare function evaluateInEnvir<OtherInfo>(expr: RNode<OtherInfo & ParentInformation>, envir: EnvirResolution<OtherInfo> | undefined, rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
23
+ /**
24
+ * The exits that leave a construct `return` leaves only itself (`local`, `eval`). If there is such a `return`, it may preempt
25
+ * every other exit, which therefore only happens if the construct is not left that way.
26
+ */
27
+ export declare function exitsPassingReturn(exits: readonly ExitPoint[], rootId: NodeId): ExitPoint[];
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processLocal = processLocal;
4
4
  exports.evaluateInEnvir = evaluateInEnvir;
5
+ exports.exitsPassingReturn = exitsPassingReturn;
5
6
  const function_semantics_1 = require("../../../../../fn/function-semantics");
6
7
  const built_in_function_definition_1 = require("./built-in-function-definition");
7
8
  const processor_1 = require("../../../../../processor");
@@ -12,11 +13,13 @@ const known_call_handling_1 = require("../known-call-handling");
12
13
  const control_flow_1 = require("../../../../control-flow");
13
14
  const common_1 = require("../common");
14
15
  const identifier_1 = require("../../../../../environments/identifier");
16
+ const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
15
17
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
16
18
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
17
19
  const built_in_envir_utils_1 = require("./built-in-envir-utils");
18
20
  const resolve_helper_1 = require("../../../../../environments/resolve-helper");
19
21
  const environment_1 = require("../../../../../environments/environment");
22
+ const ambient_state_name_1 = require("../../../../../environments/ambient-state-name");
20
23
  /** Processes a built-in 'local' function call. */
21
24
  function processLocal(name, args, rootId, data, config) {
22
25
  if (args.length === 0) {
@@ -73,7 +76,7 @@ function processLocal(name, args, rootId, data, config) {
73
76
  const baseResult = {
74
77
  hooks: dfExpr.hooks.concat(dfEnv.hooks),
75
78
  environment: dfExpr.environment,
76
- exitPoints: dfEnv.exitPoints.concat(dfExpr.exitPoints.filter(e => e.type !== 1 /* ExitPointType.Return */)),
79
+ exitPoints: dfEnv.exitPoints.concat(exitsPassingReturn(dfExpr.exitPoints, rootId)),
77
80
  graph,
78
81
  entryPoint: rootId,
79
82
  cfgEntry,
@@ -92,11 +95,43 @@ function evaluateInEnvir(expr, envir, rootId, data) {
92
95
  (0, built_in_function_definition_1.updateNestedFunctionClosures)(dfExpr.graph, dfExpr.environment, []);
93
96
  if (envir !== undefined) {
94
97
  const environment = { level: data.environment.level, current: environment_1.REnvironment.adoptSearchPath(data.environment.current, dfExpr.environment.current) };
95
- return (0, built_in_envir_utils_1.routeWrittenToEnvir)({ ...dfExpr, environment }, envir, rootId, data.environment);
98
+ const own = envir.envirData.environment.current;
99
+ const idMap = data.completeAst.idMap;
100
+ /* a function the environment binds itself, as an active binding is, is looked up there: `evalq(a, e)` runs the `a` of `e` */
101
+ const boundInEnvir = (ref) => {
102
+ const defs = (ref.name === undefined ? undefined : own.lookup(identifier_1.Identifier.getName(ref.name)))?.filter(d => (0, identifier_1.isInGraphDefinition)(d) && d.value?.some(v => r_function_definition_1.RFunctionDefinition.is(idMap.get(v))));
103
+ for (const def of defs ?? []) {
104
+ dfExpr.graph.addEdge(ref.nodeId, def.nodeId, edge_1.EdgeType.Reads);
105
+ }
106
+ return defs !== undefined && defs.length > 0;
107
+ };
108
+ const linked = { ...dfExpr, environment, in: dfExpr.in.filter(r => !boundInEnvir(r)), unknownReferences: dfExpr.unknownReferences.filter(r => !boundInEnvir(r)) };
109
+ const routed = (0, built_in_envir_utils_1.routeWrittenToEnvir)(linked, envir, rootId, data.environment);
110
+ return { ...routed, environment: sessionStateWrittenBy(dfExpr, routed.environment) };
96
111
  }
97
112
  const environment = environment_1.REnvironment.popLocal(dfExpr.environment);
98
113
  /* definitions of the local scope vanish with it, only what escaped it may bubble up */
99
114
  const out = dfExpr.out.filter(o => o.name !== undefined && resolve_helper_1.Resolve.byNameAndType(o.name, environment, o.type)?.some(d => d.nodeId === o.nodeId));
100
115
  return { ...dfExpr, environment, out };
101
116
  }
117
+ /** The state of the session `dfExpr` writes (options, sinks, the device) is the same whatever environment it is evaluated in, so it stays written for the caller as well: `local(options(digits = 3), envir = e)`. */
118
+ function sessionStateWrittenBy(dfExpr, environment) {
119
+ for (const [name, definitions] of environment_1.REnvironment.findGlobal(dfExpr.environment.current).memory) {
120
+ for (const definition of ambient_state_name_1.AmbientStateName.is(name) ? definitions : []) {
121
+ if (dfExpr.graph.hasVertex(definition.nodeId)) {
122
+ /* the caller keeps what it knew besides, as the evaluation need not have replaced it */
123
+ environment = environment_1.REnvironment.define({ ...definition, name }, true, environment, true);
124
+ }
125
+ }
126
+ }
127
+ return environment;
128
+ }
129
+ /**
130
+ * The exits that leave a construct `return` leaves only itself (`local`, `eval`). If there is such a `return`, it may preempt
131
+ * every other exit, which therefore only happens if the construct is not left that way.
132
+ */
133
+ function exitsPassingReturn(exits, rootId) {
134
+ const returns = exits.some(e => e.type === 1 /* ExitPointType.Return */);
135
+ return exits.filter(e => e.type !== 1 /* ExitPointType.Return */).map(e => returns && e.type !== 0 /* ExitPointType.Default */ ? { ...e, cds: (0, info_1.withCds)(e.cds, [{ id: rootId, when: true }]) } : e);
136
+ }
102
137
  //# sourceMappingURL=built-in-local.js.map
@@ -45,6 +45,10 @@ function processRecall(name, args, rootId, data, config) {
45
45
  }
46
46
  if (closure) {
47
47
  information.graph.addEdge(rootId, closure, edge_1.EdgeType.Calls);
48
+ /* `sys.function()` hands back the closure it runs in, which a call on its result (`sys.function()(n - 1)`) runs */
49
+ if (config?.unknownOnNonZeroArg) {
50
+ information.graph.addEdge(rootId, closure, edge_1.EdgeType.Returns);
51
+ }
48
52
  // also kill the name of the recall function
49
53
  const r = information.graph.getVertex(rootId);
50
54
  if (vertex_1.DfgVertex.isFunctionCall(r)) {