Type inference from default expression doesn’t compile in free function #72199
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
expressions
Feature: expressions
type checker
Area → compiler: Semantic analysis
Uh oh!
There was an error while loading. Please reload this page.
Description
A function definition that relies on Type inference from default expression (SE-0347) compiles when it's defined inside a type (a method), but does't compile when it's defined as a free function.
Reproduction
As a method, this compiles:
But: the same function signature as a free function doesn't compile:
Expected behavior
The free function should compile.
Environment
macOS 14.3, Xcode 15.3 (Swift 5.10)
Additional information
Forum thread where this is being discussed: https://forums.swift.org/t/type-inference-from-default-expression-doesnt-compile-in-free-function/70521/3
The text was updated successfully, but these errors were encountered: