Skip to content

[SR-6603] Syntax Error Reported By Compiler But Code Is Correct #49153

@Frizlab

Description

@Frizlab
Previous ID SR-6603
Radar rdar://problem/36054961
Original Reporter @Frizlab
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 9.2 (9C40b)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee @xedin
Priority Medium

md5: f71dbb5c51fe5652f94c69e6b7e9a619

Issue Description:

The following code, which IMHO have a valid syntax, does not compile with the compiler error “‘inout String’ is not convertible to ‘String’”:

func take(closureDictionary: [String: (inout String, Range<String.Index>, String) -> Void]) {}
take(closureDictionary: ["abc": { str, range, _ in
{{ str.replaceSubrange(range, with: str[range].reversed())}}
}])

Funnily enough, this one does:

func take(closureDictionary: [String: (inout String, Range<String.Index>, String) -> Void]) {{{}}}
take(closureDictionary: ["abc": { str, range, _ in
{{ ()}}
{{ str.replaceSubrange(range, with: str[range].reversed())}}
}])

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselftype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions