Skip to content

Conversation

@akramhany
Copy link
Contributor

Fix #8686


I did the following changes:

  • refactor extract_len function to remove any unused cases.
  • modify the visit_FunctionType verification check to allow using any variables that are either external or defined in a parent scope.

@certik
Copy link
Contributor

certik commented Oct 23, 2025

For arrays we insert autogenerated simple functions to handle this case. For strings it looks like we just link the global variable directly for subroutines (that already work), so this PR just follows the same design, which is fine for now.

if (is_a<ASR::Variable_t>(*s) && is_a<ASR::ExternalSymbol_t>(*x.m_v)) {

// Allow any variable that is either external or is not defined in this scope to pass FunctionType verification
if (is_a<ASR::Variable_t>(*s) && (is_a<ASR::ExternalSymbol_t>(*x.m_v) || !current_symtab->get_symbol(x_mv_name))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Only do it for strings --- check that the type is a character. Disallow for anything else.

@certik certik added the Tests::Run-Exhaustive Run exhaustive checks in a PR label Oct 25, 2025
@certik certik merged commit b5f16c3 into lfortran:main Oct 25, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tests::Run-Exhaustive Run exhaustive checks in a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function with character return sets length incorrectly

2 participants