Skip to content

Conversation

@EagleoutIce
Copy link
Member

No description provided.

@EagleoutIce EagleoutIce requested a review from Copilot January 3, 2026 21:40
@EagleoutIce EagleoutIce linked an issue Jan 3, 2026 that may be closed by this pull request
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements basic support for the on.exit hook mechanism in flowR's dataflow analysis. The on.exit function in R allows registering cleanup code that executes when a function exits, regardless of how the exit occurs (normal return, explicit return, or error). The implementation includes:

  • Core hook infrastructure with domination analysis to handle exit point overwriting
  • Built-in processor for on.exit that wraps expressions into function definitions
  • Hook compaction logic to remove redundant and dominated hooks
  • Comprehensive test coverage for various on.exit scenarios
  • Documentation updates marking hooks as "partially supported"

Key Changes

  • New hooks.ts module defining KnownHooks enum and hook management functions
  • Extended DataflowCfgInformation to track registered hooks within subtrees
  • Built-in processor for on.exit that handles the add and after parameters
  • Hook execution integrated into function definition processing with exit point domination
  • Updated call graph generation to include hook calls

Reviewed changes

Copilot reviewed 55 out of 58 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/dataflow/hooks.ts New file defining hook types, compaction logic, and utilities for managing registered hooks
src/dataflow/info.ts Added hooks field to DataflowCfgInformation, new overwriteExitPoints function for exit point domination
src/dataflow/internal/process/functions/call/built-in/built-in-register-hook.ts New built-in processor that transforms on.exit calls into hook registrations
src/dataflow/internal/process/functions/call/built-in/built-in-function-definition.ts Processes exit hooks, calls them, and handles exit point domination
src/dataflow/environments/default-builtin-config.ts Registers on.exit as a hook registration function (moved from unknown side effects)
src/dataflow/graph/call-graph.ts Updated to include hook calls in call graph
test/functionality/dataflow/processing-of-elements/functions/dataflow-function-on-exit.test.ts New comprehensive test suite covering various on.exit scenarios
test/functionality/dataflow/call-graph/call-graph-hooks.test.ts New tests for hook behavior in call graphs
test/functionality/_helper/shell.ts Added mustNotHaveVertices and mustNotHaveEdges test configuration options
src/dataflow/internal/process/functions/call/known-call-handling.ts Changed from reverse() to toReversed() for immutability
src/util/collections/defaultmap.ts Updated return types from IterableIterator to MapIterator for type accuracy
src/util/range.ts Added invalidRange() helper function
wiki/*.md Generated documentation updates reflecting timing changes and R version updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@EagleoutIce EagleoutIce merged commit b7c1966 into main Jan 3, 2026
19 checks passed
@EagleoutIce EagleoutIce deleted the 2144-register-hooks-like-onexit branch January 3, 2026 21:49
@EagleoutIce
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Register Hooks like on.exit

2 participants