Skip to content

[SR-2354] inout parameter in subscript gives the wrong error message #44961

@swift-ci

Description

@swift-ci
Previous ID SR-2354
Radar None
Original Reporter chriseidhof (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, Parser, StarterBug
Assignee @CodaFi
Priority Medium

md5: 0bbd574dd373c16d9585687e14bb250e

Issue Description:

When I try to have an `inout` parameter in a subscript, the compiler won't let me compile:

struct X {
    subscript(x: inout Int) -> () {
      x += 1
    }
}

However, the error message could be improved. The current message is: "Parameters may not have the 'var' specifier". This should probably be something like "Subscript parameters may not have the 'inout' specifier".

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationgood first issueGood for newcomersparserArea → compiler: The legacy C++ parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions