llvm / llvm/llvm-project

[flang] semantic errors involving mismatched types could be more useful

Open
#219,453 10 comments 0 reactions 1 assignee Claimed by @hizyyo View on GitHub
flang:frontend good first issue
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

For the example below, the error message is simply "bad type or kind" which is confusing because it implies the type itself is not correct, but in reality is just mismatched with the `tsource` type for this intrinsic.

I included both the current flang message and gfortran's error message below. Gfortran's is a better message, but I think an even better message would also include the mismatched and expected type. Something like:

"`fsource=REAL(8)` argument of `merge` intrinsic must be the same type and kind as `tsource=REAL(4)`"

I dont know how generic these messages are for the intrinsics but I'm guessing similar ones exist outside `merge`

```fortran
subroutine domerge(r,f,m)
real(8) :: r, f
logical :: m
r = merge(1.0,f,m)
end
```

flang:

```
/app/example.f90:6:17: error: Actual argument for 'fsource=' has bad type or kind 'REAL(8)'
r = merge(1.0,f,m)
^
```

gfortran:

```
Error: 'fsource' argument of 'merge' intrinsic at (1) must be the same type and kind as 'tsource'
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.