- Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
| Previous ID | SR-3680 |
| Radar | None |
| Original Reporter | @lilyball |
| Type | Bug |
Environment
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, DiagnosticsQoI, TypeChecker |
| Assignee | None |
| Priority | Medium |
md5: f6c5147ee90b20316576f2735e2456c7
Issue Description:
Given the following code:
protocol HasFoo { var foo: String { get } } protocol CanSetFoo { var foo: String { get set } } extension HasFoo where Self: CanSetFoo { func bar() { self.foo = "bar" } }The method bar() can't compile because it's not marked as mutating. But the error is wrong. The expected error is:
bar.swift:9:19: error: cannot assign to property: 'self' is immutable self.foo = "bar" ~~~~ ^ bar.swift:8:20: note: mark method 'mutating' to make 'self' mutable func bar() { ^ mutating But the actual error the compiler returns is:
bar.swift:9:18: error: cannot assign to property: 'foo' is a get-only property self.foo = "bar" ~~~~~~~~ ^ Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis