Skip to content

Comments

Fix crash on generic call to local function (#6671)#6679

Merged
zygoloid merged 4 commits intocarbon-language:trunkfrom
TechWizard9999:fix-local-function-mangle-crash
Feb 20, 2026
Merged

Fix crash on generic call to local function (#6671)#6679
zygoloid merged 4 commits intocarbon-language:trunkfrom
TechWizard9999:fix-local-function-mangle-crash

Conversation

@TechWizard9999
Copy link
Contributor

Summary

  • Avoid crash in MangleInverseQualifiedNameScope by skipping missing name scopes (local functions have no parent scope).
  • Add regression test: toolchain/lower/testdata/function/generic/local_function.carbon.

@TechWizard9999 TechWizard9999 requested a review from a team as a code owner January 31, 2026 16:36
@TechWizard9999 TechWizard9999 requested review from chandlerc and removed request for a team January 31, 2026 16:36
@google-cla
Copy link

google-cla bot commented Jan 31, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@danakj
Copy link
Contributor

danakj commented Feb 2, 2026

You'll need to sign the CLA before we can do much here

@TechWizard9999
Copy link
Contributor Author

hi @danakj ,
I have signed the CLA please take a look into it

@danakj
Copy link
Contributor

danakj commented Feb 2, 2026

Thanks, I re-ran the check. It seems that tests are failing. Have you tried running the test suites locally?

@TechWizard9999
Copy link
Contributor Author

@danakj @zygoloid
I've updated the test file with the complete LLVM IR output as requested. Could you please approve the workflows to run and take a look when you have a moment?
Please let me know if there is anything else needed.

Copy link
Contributor

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

Thanks! Just a request for a TODO comment then I think this is good to go.

}
if (!name_scope_id.has_value()) {
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll need to include something here to avoid mangling collisions. For example:

fn F(T:! Core.Copy, y: T, b: bool) -> T {
  if (b) {
    fn G(x: T) -> T { return x; }
    return G(y);
  } else {
    fn G(x: T) -> T { return x; }
    return G(y);
  }
}

fn Run() -> i32 {
  return F(i32, 0, true);
}

Here we need to give the two different G functions different mangled names. But I don't think we have a good way to handle this right now. We probably can't do much better in general than some kind of sequential numbering scheme.

Can you add a TODO: comment here so we don't forget?

@chandlerc chandlerc removed their request for review February 6, 2026 00:03
@zygoloid zygoloid enabled auto-merge February 19, 2026 00:00
@zygoloid zygoloid added this pull request to the merge queue Feb 20, 2026
Merged via the queue into carbon-language:trunk with commit 41f47c0 Feb 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants