[~breaking] Fix issue where explicitly imported macros aren't detected as imported#159
[~breaking] Fix issue where explicitly imported macros aren't detected as imported#159ericphanson merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request fixes issue #97 where explicitly imported macros (like @argcheck) were incorrectly being flagged as implicit imports. The fix enables the import analysis to recognize macro names (K"MacroName" and K"StringMacroName") in addition to regular identifiers (K"Identifier") when analyzing import statements.
Changes:
- Modified
analyze_import_typefunction to handle macro names in import statements - Added comprehensive test coverage for the macro explicit import scenario
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/get_names_used.jl | Extended analyze_import_type to recognize K"MacroName" and K"StringMacroName" kinds in import analysis |
| test/issue_97.jl | Added test module with macro definition and explicit macro import to reproduce the reported issue |
| test/issue_97_test.jl | Added tests verifying that explicitly imported macros are correctly recognized and not flagged as implicit imports |
| test/runtests.jl | Integrated the new test suite into the main test runner |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@giordano Oceananigans integration test is failing here; looks like this bugfix has the effect of finding stale macro imports correctly whereas before I guess they were ignored. It looks like This is unfortunate that it wasn't caught before so this will probably cause some test failures even though it is a bugfix. We could change this as v2 of ExplicitImports but not sure it's worth it. |
|
Can you just skip that single module in the integration test? |
|
BTW, I noticed |
Alternatively, until a new version of Oceananigans with that PR merged is tagged, how about running integration tests with In any case, please wait for CliMA/Oceananigans.jl#5135 to be merged before merging this PR, otherwise we'll suddenly get test failures 😬 |
|
Ok, now you can use commit CliMA/Oceananigans.jl@8a67381 via |
|
I asked on the open source Julia slack whether or not package maintainers think this should be a breaking change (ExplicitImports v2). There was a fair bit of discussion with most maintainers saying no, it's a bugfix semantically and therefore should be treated as one in semver versioning, with these additional reasons:
Though the main reason seemed to be that it is a bugfix and to follow normal semver. I have my reservations with this; I think v2 could be a better route for the following reasons:
Since the consensus is for it to be a patch release though, I think it's worth trying that and seeing if there is backlash against the tests starting to fail. We can always change approach next time. |
closes #97
The added tests fail without the fix: