Skip to content

[SR-15305] Postfix #if expressions want necessary newline removed #303

@klanchman

Description

@klanchman
Previous ID SR-15305
Radar None
Original Reporter @klanchman
Type Bug
Environment
  • macOS 11.6 (20G165)

  • swift-format 0.50500.0, release configuration

Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels Bug
Assignee None
Priority Medium

md5: 06f5c44e7c1b5b10eb313c28ce66331b

Issue Description:

When using swift-format in release configuration with default settings, using postfix #if expressions causes swift-format to remove a necessary newline.

Using the code from the evolution proposal, swift-format lint outputs a warning:

VStack {
  Text("something") <<< (swift-format) warning: [RemoveLine]: remove line break
  #if os(iOS)
  .iOSSpecificModifier()
  #endif
  .commonModifier()
}

Formatting results in code that causes a compiler error:

VStack {
  Text("something")#if os(iOS) <<< (Swift) error: Consecutive statements on a line must be separated by a newline
  .iOSSpecificModifier()
  #endif
  .commonModifier()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions