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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] verification of lowering to FIR failed with "'hlfir.minval' op result must have the same element type as ARRAY argument"
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    Reproducible on Godbolt:
https://godbolt.org/z/T5MeEa7r3

Reproducer:
```
 character(3) :: char(3, 4)
    char = 'abc'

    associate (y=>func(char))
        associate (item => y(1:2)//'aa')
        end associate
    end associate

    contains

    function func(char)
       character(:), allocatable :: func(:)
 character(3) :: char(3, 4)

       func = minval(char//' ', dim=1)
 end function
end
```

If I use `-flang-deprecated-no-hlfir` option, the following TODO message is obtained.
```
error: loc("/app/example.f90":15:8): /root/llvm-project/flang/lib/Lower/ConvertExpr.cpp:3412: not yet implemented: gather rhs LEN parameters in assignment to allocatable
```
https://godbolt.org/z/Enj4Gcajh
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclFFvozgQxz-N8zJKBDYEeOCBa8Kq0t6tVO3LPQ4wgHsGI9ukm_v0J5t0m20rnbQSQvLf4__YvxkbrZXDTFSy9A-Wnna4ulGb8p89GqNf7K7R3bV8osXobm1lowj0DF9012jlmKhYdGJRNTq3WD_iNeP1sM0etBkYr_9lvP6e_klnzIzYwrf_qymZnz7sGN2-MIR2RIOtI8N4LhgvwEeKTd-kB0gYL27hAGEGmDgB4xk2LePZfUofgdbqVqIjYDy_MnFi4tyvc8t4vtkWvxh-WCIdTbAtgyvjecxExcOqOnwZos_63oPm7s3nbeoT-e4wenYoZ_te99t1Us_wbt_3Ce_RhcoUHhYqpVt06Ot4Y3nzuMX8Dvdf8nq7UIBJzhdUP3d3gwOBzQN0cmLiFL-l9CBez7VJNHefdsX2f-zhEVZLwI7Rvlc4D_uOFkMtOur2s96PqpeGHSPQS_DkD-BGgl4rpV_kPMD3b6dvMJG1OBBIC7rxsKk7fJqVjNG-UUHpgItzxmtcFsZr-oHToujQF5GXRRWnTFS5P5uogPHaaO0Yr5W6TPvF6Gdq_TBs2suyYbz-ql887vpBzxcy7vxjMYd2WZioRBJ7U5i1gys5kD7ZRLOjzssDupEMmNHC1_NfsKDBiRwZC3KG7Xb7YHD6vvqfnvH_rvF5fk6-tPg87rpSdIUocEdlnEXHY5wdj8VuLHuRYtylPO_anNqkofiY5lmXZV3TUNLHO1nyiCdRLKKY8ywpDkWOedEkfn0bYVGwJKIJpTp4Wj73Tlq7UpkVRZHuFDakbHirOL8B5P7ZMmWg26yDZUmkpHX2zcFJp8IDV4cV6QkuZGQvWwy3SPegPH3fFE5D_fgEPUpFHbxIN0IodRba6fDa1BnoBQzZVTmYVutgxAuF_rI4EdBWIHDXhQAtVE9P1d-AZli9zDjfrUaV73BLN67NodXTrVU-dkwgYRmvA4z_AgAA__9m9rBP">