Skip to content

[SR-10088] Subscript overloads are incorrectly allowed to differ by escaping-ness #52490

Closed
@hamishknight

Description

@hamishknight
Previous ID SR-10088
Radar None
Original Reporter @hamishknight
Type Bug
Status Resolved
Resolution Done
Environment

Swift version 5.0-dev (LLVM 94d957ca75, Swift f07a84a)
Target: x86_64-apple-darwin18.2.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, StarterBug, TypeChecker
Assignee jumhyn (JIRA)
Priority Medium

md5: d6e10743f8e36163cbd39a4e83fc2569

Issue Description:

For functions, we don't allow overloads to differ by escaping-ness:

struct S {
  func foo(_ fn: () -> Void) {}
  func foo(_ fn: @escaping () -> Void) {} // error: Invalid redeclaration of 'foo'
}

However we do allow this for subscripts:

struct S {
  subscript(_ fn: () -> Void) -> Int { return 0 }
  subscript(_ fn: @escaping () -> Void) -> Int { return 0 } // Okay
}

We should reject such subscript overloads like we do with functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfgood first issueGood for newcomerstype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions