Skip to content

Fix duplicate atom removal and preserve cross-space definitions - #258

Open
Yadelew-zemene wants to merge 2 commits into
trueagi-io:mainfrom
Yadelew-zemene:fix/remove-atom-duplicates
Open

Yadelew-zemene wants to merge 2 commits into
trueagi-io:mainfrom
Yadelew-zemene:fix/remove-atom-duplicates

Conversation

@Yadelew-zemene

Copy link
Copy Markdown

Summary

Fixes #251 by correcting how remove-atom removes atoms and compiled function definitions.

Previously, removal could delete every matching duplicate from a space, and could remove compiled definitions that should have remained available through another space.


Changes

  • Remove only one matching atom
    Replaced retractall/1 with retract/1, so a single call removes one matching instance instead of all duplicates.

  • Make type-declaration cleanup conditional
    The type-declaration cache cleanup now runs only when a matching atom was actually removed.

  • Remove one matching compiled definition
    Changed the compiled-clause removal logic to remove a single matching translated clause rather than erasing every matching clause.

  • Add regression tests
    Added tests/test_remove_atom.pl, covering:

    • duplicate atoms
    • identical function definitions in different spaces
    • different definitions in different spaces
    • removal of the final definition
  • Integrate the tests
    Updated test.sh to run the new regression tests.


Testing


Expected behavior

After this fix:

  1. Removing one duplicate atom leaves the remaining copy in the space.
  2. Removing a function definition from one space preserves the definition available through another space.
  3. Removing the last definition makes the function unavailable.

Related issue

Fixes #251

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.

Remove-atom duplicates and callables

1 participant