<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/142481>142481</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Defined assignment resolution error
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DanielCChen
</td>
</tr>
</table>
<pre>
Consider the following code:
```
module m
type base
integer :: i
contains
procedure :: bassgn
generic :: assignment(=) => bassgn
end type
type, extends(base) :: child
integer :: j
contains
procedure :: cassgn
generic :: assignment(=) => cassgn
end type
type container
class(base), allocatable :: b1
class(child), allocatable :: c1
end type
contains
impure elemental subroutine bassgn ( a, b )
class(base), intent(out) :: a
type(base), intent(in) :: b
a%i = b%i + 1
select type ( a )
type is ( child )
a%j = b%i + 2
end select
end subroutine
impure elemental subroutine cassgn ( a, b )
class(child), intent(out) :: a
type(child), intent(in) :: b
a%i = b%i + 2
a%j = b%j + 2
end subroutine
end module
program genericAssignmentDtIntrinAssgn029
use m
type(container) :: c1, c2, c3
pointer :: c2
allocatable :: c3
allocate ( c2, c3 )
allocate ( c2%b1, source = child(1,2) )
allocate ( c2%c1, source = child(9,10))
c1 = c2
c3 = c1
select type ( g => c1%b1 )
type is ( child )
select type ( h => c1%c1 )
type is ( child )
print *, g%j !! ERROR
end select
end select
select type ( g => c3%b1 )
type is ( child )
select type ( h => c3%c1 )
type is ( child )
print *, g%j !! ERROR
end select
end select
end program
```
Expected output:
```
3
4
```
Flang outputs:
```
0
0
```
Both assignment `c1 = c2` and `c3 = c1` should resolve to `cassgn` for the `b1` component as its dynamic type is `child`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8Vt1u7CYQfhr2Bp0I47VjX_jCyWalXlXKG2CYtYkwWIDTk7evwD_r_Wtz2qpWEgc8HzPfNzMAc062GqBC2QvKDjs2-s7Y6sC0BPX62oHeNUZ8Va9G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