<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/129726>129726</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Error due to order of specific procedures in generic interface
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ivan-pi
      </td>
    </tr>
</table>

<pre>
    Given the following module, simply changing the order of the specific procedure in a type-bound method results in an error:

```fortran
module collisions
implicit none

type :: Spaceship
contains
#ifdef WORKING
 procedure, private, pass(x) :: collide_x => collide_ss, collide_sa  ! Works
#else
    procedure, private, pass(x) :: collide_x => collide_sa, collide_ss  ! Breaks
#endif
    procedure, private, pass(y) :: collide_y => collide_as
    generic :: collide => collide_x, collide_y
end type

type :: Asteroid
end type

contains

subroutine collide_as(x,y)
 class(Asteroid) :: x
    class(Spaceship) :: y
    print *, "a/s"
end subroutine
subroutine collide_sa(x,y)
    class(Spaceship) :: x
 class(Asteroid) :: y
    print *, "s/a"
end subroutine
subroutine collide_ss(x,y)
    class(Spaceship) :: x
    class(Spaceship) :: y
 print *, "s/s"
end subroutine

end module
```

```
$ flang-new -c c4.F90 
error: Semantic errors in c4.F90
./c4.F90:12:16: error: Generic 'collide' may not have specific procedures 'collide_x' and 'collide_y' as their interfaces are not distinguishable
      generic :: collide => collide_x, collide_y
                 ^^^^^^^
./c4.F90:25:12: Procedure 'collide_x' of type 'spaceship' is bound to 'collide_sa'
  subroutine collide_sa(x,y)
             ^^^^^^^^^^
./c4.F90:20:12: Procedure 'collide_y' of type 'spaceship' is bound to 'collide_as'
  subroutine collide_as(x,y)
             ^^^^^^^^^^
$ flang-new -c -DWORKING c4.F90 
$ flang-new --version
Homebrew flang-new version 19.1.4
Target: x86_64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /usr/local/Cellar/flang/19.1.4/libexec
Configuration file: /usr/local/Cellar/flang/19.1.4/libexec/flang.cfg
Configuration file: /usr/local/etc/clang/x86_64-apple-darwin23.cfg
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVl1vozgU_TXOy1UQGEjggQemLd3RSrurnZHmcWTgAt51bGSbNPn3KzvkY9J0m6mmQm2x78e5x_cezIzhvUQsSPqJpI8LNtlB6YJvmVyOfFGrdl888y1KsANCp4RQL1z2sFHtJJDQBzB8M4o9NAOTvdtxdkq3qEF1_sWM2PCONzBq1WA7aQQugYHdj7is1SRb2KAdVAsazSSs8dsSUGulSVyS0D-r8PB0SlvNJAnLAwZolBDccCUNCUsHhjfcglQSD54uD7g4cQlfRtagGfhIwrJR0jLuvQiNeddiB9_-_Pv3z388k7A8o3VFjppvmT38y4whNNsRmh-jegQtft8BiR9J_HRacJYP5zcGQGgE35T-d86KwjiUAPBr8rEf8plDvk8a2SmhbHl3X8b9jYz764zMzMF6lKh5c-Vwbb67xLcnYYmy9Y3w-qhKY1Er3r4yujy3sDRTrdVkucRLTJ6vB1eBg9eIQ0WnkOfCdjP8o8m5Qc42-xNfXFogtHRFEEoZoZUhlM4Iz0huw3KH8wOsd9Lu3oH-FixDaMV-AtY1W_fAuoexW7jeomtem1XlYtqvht83cQKdYLJfSnyBZQNNElR5CC7ErBjwBTdMWt4cNMQLysGKhGVAaDW_xGVE3a-V8zk5Px87ma5njghdw4btQSoLA9vekjRzYe66fA1Mtpdre79mnCJyDVxa1J0jDphGH7jlxnLZT9wMrBZHVfjwYMH1D0mfbjxXfND0SAr8dVLr68qcrvtBpWtzPvw1cAMHObfq0sf1_dojunMo3oH8Jvbw_7HvP4DdScmb2F_pzE9hf9XHy8f563PR0VdGyy1q96UjYfmb2mCt8eVie96EKA-iICFh-ZXpHq0f2mz1fZUs2TgKXLZMv3BJ42AVuIH4OmhkfvZQONtRGe6G_LM0lgmB7SP3c0FoNRlNaCVUwwSh1QMKwdyCh0BoNSemleA17rAhYfmgZMf7STPrk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