Fix/duplicate import error throwing#157
Open
ermijeremy wants to merge 6 commits intotrueagi-io:mainfrom
Open
Conversation
patham9
requested changes
Apr 15, 2026
Collaborator
patham9
left a comment
There was a problem hiding this comment.
Thank you very much!
Only: there should be no import error being generated.
Often libraries depend on same core libraries, it is normal.
It only should ensure that no library is loaded twice.
Contributor
Author
@patham9 it no longer throws error instead if a duplicate import is found it just ignores it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
Closes #154
Summary
Prevent duplicate
import!loads by tracking absolute import paths and ignoring duplicate imports.What Changed
import!now normalizes every import to an absolute path..pyimports resolve to an absolute path and import the Python module..mettapath and load the MeTTa file.imported_file/1.Why This Fixes the Issue
Previously, repeated
import!calls could reload the same file multiple times, causing duplicated definitions and inconsistent behavior.By normalizing to a canonical absolute filename and recording it in
imported_file/1, any subsequent import of the same file is detected and rejected reliably.How It Works (Mechanics)
Fileto an absolute path.imported_file(AbsPath):assertz(imported_file(AbsPath)).Tests