Skip to content

[SR-3167] Improve error when using keywords as identifiers #45755

@belkadan

Description

@belkadan
Previous ID SR-3167
Radar rdar://problem/25881880
Original Reporter @belkadan
Type Improvement
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, DiagnosticsQoI, Parser, StarterBug
Assignee @belkadan
Priority Medium

md5: dfc0ab758b4f132463ad177824c23f7f

Issue Description:

func switch() { }
repl.swift:1:6: error: expected identifier in function declaration
func switch() { }
     ^

We can do better than this. Someone inside Apple suggested "keyword 'switch' found where an identifier should be in a function's name. Try picking a different name for the function or putting backticks (`) around the name." The suggested fixes (the second sentence) should probably be two separate notes rather than crammed into the main diagnostic.

Metadata

Metadata

Assignees

Labels

compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationgood first issueGood for newcomersimprovementparserArea → compiler: The legacy C++ parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions