Skip to content
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

[SR-3525] Bad diagnostic when passing stored property of non-mutating self as inout #46113

Closed
slavapestov opened this issue Jan 2, 2017 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@slavapestov
Copy link
Member

Previous ID SR-3525
Radar None
Original Reporter @slavapestov
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee None
Priority Medium

md5: 2c8db6c7f109d2ef9107b22d7e0d751c

Issue Description:

The first case g1() is OK; g2() and g3() are busted:

struct G<T> {}

func f1(_: inout G<Int>) {}
func f2<T>(_: inout G<T>) {}

func g1(t: G<Int>) {
  let _ = f1(&t) // cannot pass immutable value as inout argument: 't' is a 'let' constant
}

func g2(t: G<Int>) {
  let _ = f2(&t) // cannot convert value of type 'G<Int>' to expected argument type 'G<_>'
}

func g3<T>(t: G<T>) {
  let _ = f2(&t) // cannot convert value of type 'G<T>' to expected argument type 'G<_>'
}
@slavapestov
Copy link
Member Author

This was fixed in 4.2 apparently – thanks @xedin!

io.swift:7:14: error: cannot pass immutable value as inout argument: 't' is a 'let' constant
  let _ = f1(&t) // cannot pass immutable value as inout argument: 't' is a 'let' constant
             ^~
io.swift:11:14: error: cannot pass immutable value as inout argument: 't' is a 'let' constant
  let _ = f2(&t) // cannot convert value of type 'G<Int>' to expected argument type 'G<_>'
             ^~
io.swift:15:14: error: cannot pass immutable value as inout argument: 't' is a 'let' constant
  let _ = f2(&t) // cannot convert value of type 'G<T>' to expected argument type 'G<_>'

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

1 participant