[SR-10083] When Swift can't determine the return type of a closure, misleading and incorrect errors are shown instead #52485
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
Attachment: Download
Environment
macOS 10.14
Swift 4.2/Swift 5 beta toolchain
In order to run the zipped project, run `swift run` inside its directory. Dependencies will be fetched and compiled.
Additional Detail from JIRA
md5: c12fee4b6ba2c0734b38fdf25e653786
Issue Description:
Given the following code which can be found in `main.swift` in the attached project
error: type 'PathComponentsRepresentable' does not conform to protocol 'ExpressibleByStringLiteral'
router.get("users") { req in
^
{\code}
While that error is technically correct, that's not the problem here. `router.get` is defined as
import Vapor
let app = try Application()
let router = try app.make(Router.self)
router.get("users") { req -> String in // CHANGE HERE: Explicit return type added
let id = 1
return "User #(id)"
}
try app.run()
{\code}
The text was updated successfully, but these errors were encountered: