Skip to content

Add explicit regression test for issue #363#367

Open
krystophny wants to merge 1 commit intojameskermode:masterfrom
krystophny:codex/fix-issue-363
Open

Add explicit regression test for issue #363#367
krystophny wants to merge 1 commit intojameskermode:masterfrom
krystophny:codex/fix-issue-363

Conversation

@krystophny
Copy link
Copy Markdown
Contributor

@krystophny krystophny commented Mar 28, 2026

Summary

Closes #363.

Current master already emits the selective use ..., only: import needed to avoid the name collision reported in #363, but there was no dedicated regression coverage for that exact case.

This PR adds an issue363_missing_only_import example that:

  • reproduces a module-level variable / procedure-argument name collision
  • asserts that the generated wrapper uses use global_mod, only: print_number
  • runs through both the regular wrapper flow and the Direct-C Meson flow

Verification

Historical failure on v0.3.0

$ /tmp/f90wrap-v030-venv/bin/python -m f90wrap -m global_mod global_mod.f90
$ sed -n '1,8p' f90wrap_global_mod.f90
! Module global_mod defined in file global_mod.f90

subroutine f90wrap_global_mod__print_number(number)
    use global_mod
    implicit none
...
$ gfortran -c global_mod.f90
$ gfortran -c f90wrap_global_mod.f90
f90wrap_global_mod.f90:7:33:

    7 |     integer, intent(in) :: number
      |                                 1
Error: Name ‘number’ at (1) is an ambiguous reference to ‘number’ from current program unit
f90wrap_global_mod.f90:3:45:

    3 | subroutine f90wrap_global_mod__print_number(number)
      |                                             1~~~~~
Error: Symbol ‘number’ at (1) has no IMPLICIT type

Current branch

$ cd examples/issue363_missing_only_import
$ PATH="/tmp/f90wrap-venv/bin:$PATH" PYTHON=/tmp/f90wrap-venv/bin/python make test
...
Issue #363 test passed: generated wrapper uses selective import

$ PATH="/tmp/f90wrap-venv/bin:$PATH" PYTHON=/tmp/f90wrap-venv/bin/python DIRECTC=yes make -f Makefile.meson test
...
Issue #363 test passed: generated wrapper uses selective import

$ cd /tmp/f90wrap-test-run
$ PATH="/tmp/f90wrap-venv/bin:$PATH" /tmp/f90wrap-venv/bin/python -m unittest test.test_directc
.............................
----------------------------------------------------------------------
Ran 29 tests in 0.014s

OK

@krystophny krystophny marked this pull request as ready for review March 28, 2026 16:06
@krystophny krystophny changed the title [codex] Add regression coverage for issue 363 Add explicit regression test for issue #363 Mar 28, 2026
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.

Missing only clause to use statement causing compilation errors

1 participant