carbon-language/carbon-lang

Call to local function inside generic function fails

已关闭

#6,793 创建于 2026年2月25日

 (3 条评论) (0 个反应) (0 位负责人)C++ (1,535 个派生)batch import
good first issuetoolchain

仓库指标

星标
 (33,701 个星标)
PR 合并指标
 (平均合并 3天 6小时) (30 天内合并 129 个 PR)

描述

Description of the bug:

A call to a local function defined inside a generic function fails with a compiler error.

What did you do, or what's a simple way to reproduce the bug?

fn F(unused T:! type) {
  fn Local() {}
  Local();
}

What did you expect to happen?

This should compile successfully.

What actually happened?

The compiler cannot deduce the generic parameters of the enclosing function while deducing parameters of the local function.

  // CHECK:STDERR: demo.carbon:[[@LINE+7]]:3: error: cannot deduce value for generic parameter `T` [DeductionIncomplete]
  // CHECK:STDERR:   Local();
  // CHECK:STDERR:   ^~~~~~~
  // CHECK:STDERR: demo.carbon:[[@LINE-4]]:3: note: while deducing parameters of generic declared here [DeductionGenericHere]
  // CHECK:STDERR:   fn Local() {}
  // CHECK:STDERR:   ^~~~~~~~~~~~
  // CHECK:STDERR:

Any other information, logs, or outputs that you want to share?

No response

贡献者指南