swiftlang/swift

Bad diagnostic for `any P!`

Open

#72,662 创建于 2024年3月28日

在 GitHub 查看
 (6 评论) (0 反应) (2 负责人)Swift (10,719 fork)batch import
TypeResolverbugcompilerdiagnostics qualityexistentialsgood first issueimplicitly unwrapped optionalsswift 6.0type checkertypesunexpected behavior

仓库指标

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

描述

Description

No response

Reproduction

protocol P {}

// error: using '!' is not allowed here; perhaps '?' was intended? [implicitly_unwrapped_optional_in_illegal_position]
// error: optional 'any' type must be written '(any P2)?' [incorrect_optional_any]
let _: any P!

Expected behavior

A single error, optional 'any' type must be written '(any P)!', as in the case of let _: any P?.

Environment

Swift version 6.0-dev (LLVM 48dc0c6fa01ce9e, Swift 19fbe5b33d423d1) Target: x86_64-apple-macosx14.0

Additional information

This https://github.com/apple/swift/labels/good%20first%20issue will suit an experienced Swift user.

贡献者指南