Skip to content

Conversation

@YashNagda17
Copy link
Contributor

Fixes #8719 addressing comments of #8720

Added Test-Case:

program test
  integer::j
  call ss(j)
  contains 
  subroutine ss (i)
    real :: i
  end subroutine
end program test

Updated Main:

$ lfortran a.f90
semantic error: Type mismatch in argument `i`: expected `real` but got `integer`
 --> a.f90:3:11
  |
3 |   call ss(j)
  |           ^ 


Note: Please report unclear, confusing or incorrect messages as bugs at
https://github.com/lfortran/lfortran/issues.

Gfortran:

$ gfortran a.f90
a.f90:3:12:

    3 |   call ss(j)
      |            1
Error: Type mismatch in argument ‘i’ at (1); passed INTEGER(4) to REAL(4)

std::string param_type_str = ASRUtils::type_to_str_fortran_expr(param_type, nullptr);
diag.add(diag::Diagnostic(
"Type mismatch in argument `" + std::string(v->m_name) +
": expected `" + param_type_str + "` but got `" +passed_type_str + "`",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
": expected `" + param_type_str + "` but got `" +passed_type_str + "`",
"`: expected `" + param_type_str + "` but got `" +passed_type_str + "`",

@YashNagda17 YashNagda17 marked this pull request as ready for review October 16, 2025 16:22
@YashNagda17
Copy link
Contributor Author

The error is due to unable to access 'https://github.com/jinangshah21/fortran-shlex.git/': Could not resolve host: github.com
Not related to made changes

Although it's second time this same error has occurred here


void handle_print(ASR::expr_t* arg, ASR::expr_t* end_expr)
{
std::printf("Inside print Arg Typ %d Enf Expr Type %d \n", arg->type, (end_expr != nullptr) ? end_expr->type : -1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be here. You can notice by the huge change in reference tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Extremely sorry for the troubles.

@certik certik marked this pull request as draft October 16, 2025 16:32
@certik certik marked this pull request as ready for review October 17, 2025 16:14
@certik certik merged commit 52106ed into lfortran:main Oct 17, 2025
14 checks passed
@certik
Copy link
Contributor

certik commented Oct 17, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passing Incompatible Types to Subroutine Args

2 participants