Skip to content

Conversation

@cristianoc
Copy link
Collaborator

No description provided.

OptionalArgs.t is now fully immutable with no mutation of declarations.

Key changes:
- OptionalArgs.t: removed mutable fields
- apply_call: pure function, returns new state
- combine_pair: pure function, returns pair of new states
- OptionalArgsState module in Common.ml for computed state map
- compute_optional_args_state: returns immutable OptionalArgsState.t
- DeadOptionalArgs.check: looks up state from map

Architecture:
- Declaration's optionalArgs = initial state (what args exist)
- OptionalArgsState.t = computed state (after all calls/combines)
- Solver uses OptionalArgsState.find_opt to get final state

This completes the pure analysis pipeline - no mutation anywhere.
Extract focused modules from Common.ml:
- Cli.ml: CLI option refs
- Pos.ml: Position utilities
- PosSet.ml, PosHash.ml: Position collections
- StringSet.ml, FileSet.ml, FileHash.ml: String/file collections
- DcePath.ml: Dead code path type (renamed from Path to avoid shadowing)
- Decl.ml: Declaration types (Kind, t, posAdjustment)
- Issue.ml: Issue types (severity, deadWarning, description, etc.)
- LocSet.ml: Location set
- OptionalArgs.ml, OptionalArgsState.ml: Optional args tracking

This eliminates the Common.ml 'kitchen sink' that was causing:
- Circular dependency issues
- Poor code organization
- Difficulty understanding module boundaries

Each module now has a single responsibility.

Signed-Off-By: Cristiano Calcagno
@cristianoc cristianoc changed the base branch from master to reanalyze-dce-plan December 9, 2025 06:36
@cristianoc cristianoc changed the title Refactor remove common module OptionnalArgs immutable and refactor: remove common module Dec 9, 2025
@cristianoc cristianoc changed the title OptionnalArgs immutable and refactor: remove common module OptionnalArgs immutable and refactor: remove Common module Dec 9, 2025
@cristianoc cristianoc merged commit 326d09f into reanalyze-dce-plan Dec 9, 2025
6 checks passed
@cristianoc cristianoc deleted the refactor-remove-common-module branch December 9, 2025 06:37
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review


P1 Badge Restore tracked deadcode baseline for reanalyze test

Removing expected/deadcode.txt makes tests/analysis_tests/tests-reanalyze/deadcode/test.sh ineffective: the script writes fresh output to that path and only checks git ls-files --modified expected, which ignores untracked files. With the baseline deleted, the file becomes untracked and the test will always report no differences even if the reanalyze dead-code output regresses.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

2 participants