swiftlang/swift

[SR-1553] [QOI] Warn on discarded binding of () result

Open

#44,162 创建于 2016年5月18日

在 GitHub 查看
 (13 评论) (0 反应) (0 负责人)Swift (10,719 fork)batch import
compilerdiagnostics qualitygood first issueimprovement

仓库指标

Star
 (69,989 star)
PR 合并指标
 (平均合并 8天 17小时) (30 天内合并 510 个 PR)

描述

Previous ID SR-1553
Radar None
Original Reporter @ddunbar
Type Improvement
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI
Assignee zsalloum (JIRA)
Priority Medium

md5: a541dcf4281d920a0880df5d3eabc2fa

Issue Description:

Swift should warn on the code below:

$ cat x.swift
func f0() -> () {}
let _ = f0()

$ swiftc -c x.swift
$

This is somewhat related to SE-0047, in that if you use let _ = ... to discard results, and then later refactor the code to not return a result, Swift won't help you find the other places in the code base to update.

贡献者指南