[SR-12682] Function builder generic parameter type inference fails #55126
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
result builders
Feature: Result builders
type checker
Area → compiler: Semantic analysis
Additional Detail from JIRA
md5: 56625d74937947d4f1c1a26936e26eef
Issue Description:
Function builder generic parameter type inference fails, even though type inference succeeds for manually-written
buildBlock
calls.Cross-posted here from https://forums.swift.org/t/function-builder-cannot-infer-generic-parameters-even-though-direct-call-to-buildblock-can/35886.
Context
Our deep learning library defines a Sequential type for sequentially composing neural network layers. It's powered by a function builder called LayerBuilder.
Sequential is currently used like this:
Ideally, we'd like the function builder to infer layer generic parameters so that only one specialization needs to be specified:
But it doesn't work:
Direct calls to
LayerBuilder.buildBlock
do type-check inferring some generic parameters, which makes me feel that this is a type inference deficiency specific to function builders:Full reproducer
Uncomment FIXME comment for type inference error:
The text was updated successfully, but these errors were encountered: