# The same named entity from different modules and/or program units cannot be referenced: bug?

**URL:** <https://fortran-lang.discourse.group/t/the-same-named-entity-from-different-modules-and-or-program-units-cannot-be-referenced-bug/7387>\
**Category:** Intel\
**Created:** [February 10, 2024, 8:52pm UTC](https://fortran-lang.discourse.group/t/the-same-named-entity-from-different-modules-and-or-program-units-cannot-be-referenced-bug/7387 "2024-02-10T20:52:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [February 10, 2024, 8:52pm UTC](https://fortran-lang.discourse.group/t/the-same-named-entity-from-different-modules-and-or-program-units-cannot-be-referenced-bug/7387/1 "2024-02-10T20:52:51Z")

</div>

I am having the following issue while trying to build Fortran Package Manager with `ifx` with a recent update:

```auto
<ERROR> Compilation failed for object " src_fpm_settings.f90.o "
STOP 1
/tmp/ifx1633921843HhfFCb/ifxrJzAnL.i90: error #6405: The same named entity from different modules and/or program units cannot be referenced. [TTABLE]

```

I believe this is the same error that @everythingfunctional has recently filed at the [Intel Compiler Forum](https://community.intel.com/t5/Intel-Fortran-Compiler/The-same-named-entity-from-different-modules-and-or-program/td-p/1529557).

Can I ask the Intel gurus on this forum if you have any advice on how to move forward with this issue?

- The failing build process can be seen [here](https://github.com/fortran-lang/fpm/actions/runs/7857302691)
- The `fpm_settings.f90` source can be seen [here](https://github.com/fortran-lang/fpm/blob/ecd23ed414183e8e63ce7db72945e8988046fa61/src/fpm_settings.f90): I have also tried to relabel the `toml_table` variable to `ttable => toml_table`, but the compilation still crashes.

If this turns out to be a compiler bug, then, also ideas to work around this issue would be higly appreciated!

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [February 10, 2024, 9:16pm UTC](https://fortran-lang.discourse.group/t/the-same-named-entity-from-different-modules-and-or-program-units-cannot-be-referenced-bug/7387/2 "2024-02-10T21:16:06Z")

</div>

Here is a guess about your problem. For a code where two modules define the same subroutine `display`

```auto
module date_ymd_mod
implicit none
type date_ymd
   integer :: year, month, day
end type date_ymd
contains
subroutine display(date)
type(date_ymd), intent(in) :: date
print "(i4.4,2('-',i2.2))", date
end subroutine display
end module date_ymd_mod
!
module date_ym_mod
implicit none
type date_ym
   integer :: year, month
end type date_ym
contains
subroutine display(date)
type(date_ym), intent(in) :: date
print "(i4.4,'-',i2.2)", date
end subroutine display
end module date_ym_mod
!
program main
use date_ymd_mod
use date_ym_mod
implicit none
call display(date_ymd(2024,2,10))
call display(date_ym(2024,2))
end program main

```

ifx correctly complains

```auto
display.f90(29): error #6405: The same named entity from different modules and/or program units cannot be referenced. [DISPLAY]
call display(date_ymd(2024,2,10))
-----^
display.f90(30): error #6405: The same named entity from different modules and/or program units cannot be referenced. [DISPLAY]
call display(date_ym(2024,2))
-----^
compilation aborted for display.f90 (code 1)

```

but when two modules have an interface for `display` ifx and gfortran accept the code:

```auto
module date_ymd_mod
implicit none
type date_ymd
   integer :: year, month, day
end type date_ymd
interface display
   module procedure display_ymd
end interface display
contains
subroutine display_ymd(date)
type(date_ymd), intent(in) :: date
print "(i4.4,2('-',i2.2))", date
end subroutine display_ymd
end module date_ymd_mod
!
module date_ym_mod
implicit none
type date_ym
   integer :: year, month
end type date_ym
interface display
   module procedure display_ym
end interface display
contains
subroutine display_ym(date)
type(date_ym), intent(in) :: date
print "(i4.4,'-',i2.2)", date
end subroutine display_ym
end module date_ym_mod
!
program main
use date_ymd_mod
use date_ym_mod
implicit none
call display(date_ymd(2024,2,10))
call display(date_ym(2024,2))
end program main

```

Output:

```auto
2024-02-10
2024-02

```

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [February 10, 2024, 9:21pm UTC](https://fortran-lang.discourse.group/t/the-same-named-entity-from-different-modules-and-or-program-units-cannot-be-referenced-bug/7387/3 "2024-02-10T21:21:27Z")

</div>

Thank you for the hint @Beliavsky.

In our case, `toml_table` is a derived type, and nowhere else is any procedure or variable, or anything defined with the same name. All that I could try to do was to locally rename it using

```auto
use fpm_toml, only: ttable=>toml_table

```

but the error message does not go away, it now points to `[TTABLE]`.

---

<div class="post-metadata">

**Author:** ![greenrongreen](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/greenrongreen/32/1249_2.png) [@greenrongreen](https://fortran-lang.discourse.group/u/greenrongreen)\
**Post date:** [February 16, 2024, 4:40pm UTC](https://fortran-lang.discourse.group/t/the-same-named-entity-from-different-modules-and-or-program-units-cannot-be-referenced-bug/7387/4 "2024-02-16T16:40:25Z")

</div>

It is a bug in ifx. the bug ID is CMPLRLLVM-52315. You can track it on [this thread](https://community.intel.com/t5/Intel-Fortran-Compiler/The-same-named-entity-from-different-modules-and-or-program/td-p/1529557) on the Intel Forum.

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [February 16, 2024, 4:58pm UTC](https://fortran-lang.discourse.group/t/the-same-named-entity-from-different-modules-and-or-program-units-cannot-be-referenced-bug/7387/5 "2024-02-16T16:58:31Z")

</div>

Thanks a lot @greenrongreen.

Not sure if would be useful, but the [single-file](https://github.com/fortran-lang/fpm/releases/download/v0.10.0/fpm-0.10.0.F90) version of fpm could be used as a reproducer for the issue. Looking forward to the fix!
