<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/143740>143740</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] ASSERTION when module and the main program are in two different files.
</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>
File mod.f
```
module m
type::base
integer(4)::id
contains
procedure::print=>printbase
end type
private::printbase
interface
subroutine printbase(b)
import::base
class(base),intent(in)::b
end
end interface
end
```
File main.f
```
module m1
use m
type, extends (base) :: child
character*20 :: name = ''
contains
procedure :: print => printChild
end type
contains
subroutine printChild (b)
class (child), intent(in) :: b
print *, b%id, b%name
end subroutine
end module
program ftpbnd509a1
use m1
type (base), target :: b1
type (child), target :: c1
class (base), pointer :: b_ptr
c1 = child (20, 'c1_test')
end
```
Flang asserts as:
```
Assertion failed: isa<To>(Val) && "cast<Ty>() argument of incompatible type!", file llvm-project/llvm/include/llvm/Support/Casting.h, line 572, decltype(auto) llvm::cast(From &) [To = fir::RecordType, From = mlir::Type]()
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/cdchen/FLANG/build/bin/flang -fc1 -triple powerpc64-ibm-aix7.2.0.0 -emit-obj -ffree-form -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu pwr7 -resource-dir /home/cdchen/FLANG/build/lib/clang/21 -mframe-pointer=all -o ftpbnd509a1.o -x f95 ftpbnd509a1.f
flang-21: error: unable to execute command: IOT/Abort trap
```
If I move the code in mod.f into main.f, it compiles successfully.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVsuO2zoS_Rp6U5BAUZZlL7xQ7NaggSAJ0o3ZBhRZsplQpEBS_fj7ASn50T33AhfX8EJmPXjq1KmyuPfqZBD3pPpCquOKT-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