Skip to content

Fix for context propagation in the presence of circular imports#204

Merged
agarciadom merged 2 commits intomainfrom
fix-203
Oct 1, 2025
Merged

Fix for context propagation in the presence of circular imports#204
agarciadom merged 2 commits intomainfrom
fix-203

Conversation

@agarciadom
Copy link
Contributor

This is a suggested fix for #203. It removes the clobbering of module contexts in EolModule::build(), and instead propagates the context via the Import::load() method.

This works more reliably in the presence of circular imports, as the parent module's context is present from the start while parsing the imported module.

Suppose we have this situation:

* circular1.egl imports circular2.egl.
* circular2.egl imports circular1.egl.
* We load and parse circular1.egl as the root module.

In this scenario, we want circular1.egl to be in the ImportManager
cache before parsing circular2.egl, so that it will be reused when
parsing circular2.egl.

This prevents the creation of a throwaway EglModule while parsing
circular2.egl (which is not used anyway, due to the loop over the
ancestors which is done in Import::load).
@agarciadom
Copy link
Contributor Author

I have added a commit that ensures that the importing module is in the cache before parsing the imported module, so that it is reused down the import tree if necessary.

@agarciadom
Copy link
Contributor Author

Reviewed and approved by @kolovos today.

@agarciadom agarciadom merged commit ffc3079 into main Oct 1, 2025
6 checks passed
@agarciadom agarciadom added this to the 2.9.0 milestone Oct 1, 2025
@agarciadom agarciadom self-assigned this Oct 1, 2025
@agarciadom agarciadom deleted the fix-203 branch October 8, 2025 18:52
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.

1 participant