Skip to content

[SR-3599] Better recovery for function names (and other decl names) with spaces #46184

@belkadan

Description

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

md5: 29eeeaf8d8066280f10404bd103f9e82

relates to:

  • SR-3600 Better recovery for trying to name an initializer, deinitializer, or subscript

Issue Description:

Nothing stops a new coder from writing something like func do something(), especially in Swift Playgrounds where we expect users who have never coded before. We should diagnose this with a nice note like "function names cannot have spaces in them", and offer a fix-it to camel-case the name instead.

(This also applies to types, where this is probably not too difficult, and properties / variables / constants, where it's a bit harder due to how patterns are parsed.)

Metadata

Metadata

Assignees

No one assigned

    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