-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugs with opaque result types in structural position #60038
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
expressions
Feature: expressions
opaque result types
Feature → types → opaque types: opaque result types
opaque types
Feature → types: opaque types
swift 5.7
type checker
Area → compiler: Semantic analysis
type inference
Feature: type inference
unexpected error
Bug: Unexpected error
Comments
slavapestov
added
the
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
label
Jul 13, 2022
CC @jckarter |
slavapestov
added a commit
to slavapestov/swift
that referenced
this issue
Jul 13, 2022
…tion Move the check where we insert UnderlyingToOpaqueExpr earlier in coerceToType(). Otherwise, returning a metatype or function type would attempt to perform a conversion instead of building a UnderlyingToOpaqueExpr. Fixes part of apple#60038.
slavapestov
added a commit
to slavapestov/swift
that referenced
this issue
Jul 13, 2022
…tion Move the check where we insert UnderlyingToOpaqueExpr earlier in coerceToType(). Otherwise, returning a metatype or function type would attempt to perform a conversion instead of building a UnderlyingToOpaqueExpr. Fixes part of apple#60038.
slavapestov
added a commit
to slavapestov/swift
that referenced
this issue
Jul 13, 2022
…tion Move the check where we insert UnderlyingToOpaqueExpr earlier in coerceToType(). Otherwise, returning a metatype or function type would attempt to perform a conversion instead of building a UnderlyingToOpaqueExpr. Fixes part of apple#60038.
slavapestov
added a commit
to slavapestov/swift
that referenced
this issue
Jul 14, 2022
…tion Move the check where we insert UnderlyingToOpaqueExpr earlier in coerceToType(). Otherwise, returning a metatype or function type would attempt to perform a conversion instead of building a UnderlyingToOpaqueExpr. Fixes part of apple#60038.
Catfish-Man
pushed a commit
to Catfish-Man/swift
that referenced
this issue
Jul 28, 2022
…tion Move the check where we insert UnderlyingToOpaqueExpr earlier in coerceToType(). Otherwise, returning a metatype or function type would attempt to perform a conversion instead of building a UnderlyingToOpaqueExpr. Fixes part of apple#60038.
AnthonyLatsis
added
compiler
The Swift compiler in itself
type checker
Area → compiler: Semantic analysis
opaque types
Feature → types: opaque types
closures
Feature: closures
labels
Dec 11, 2022
AnthonyLatsis
added
function types
Feature → types: function types
opaque result types
Feature → types → opaque types: opaque result types
unexpected error
Bug: Unexpected error
swift 5.7
type inference
Feature: type inference
expressions
Feature: expressions
and removed
closures
Feature: closures
function types
Feature → types: function types
labels
Apr 3, 2023
@slavapestov It looks like |
// https://github.com/apple/swift/blob/main/test/SILGen/opaque_result_type_structural.swift
public protocol P1 {}
extension P1 {
public func f1() -> () -> (some P1) {
let fn = { self }
return fn
}
static public func f2() -> (Self) -> (some P1) {
let fn: (Self) -> (Self) = { p in p }
return fn
}
}
public protocol P2 {}
extension P2 {
public func f1() -> some P2 {
return self
}
public func f2() -> some P2 {
return self.f1()
}
public func f3() -> () -> (some P2) {
let fn = { self.f2() }
return fn
}
static public func f4() -> (Self) -> (some P2) {
let fn: (Self) -> (Self) = { p in p.f2() }
// Cannot convert value of type 'some P2' to closure result type 'Self'
return fn
}
} I was able to repurpose the workaround from |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
expressions
Feature: expressions
opaque result types
Feature → types → opaque types: opaque result types
opaque types
Feature → types: opaque types
swift 5.7
type checker
Area → compiler: Semantic analysis
type inference
Feature: type inference
unexpected error
Bug: Unexpected error
Each of these three declarations should type check, but doesn't:
The text was updated successfully, but these errors were encountered: