nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.87k stars 637 forks source link

enumNamespaces overwrite imports #1581

Closed pronebird closed 10 months ago

pronebird commented 10 months ago

Seems like 0.52.9 overwrites the following targeted import:

import struct Network.IPv4Address

with:

import enum Network.IPv4Address

Which breaks compilation as you can imagine.

nicklockwood commented 10 months ago

D'oh - thanks, I'll get that fixed.

guillaumealgis commented 10 months ago

Seeing the same thing with

import class MyLibrary.User

being replaced with

import enum MyLibrary.User

(I'm guessing the fix is the same, I'm just signaling that the bug is not limited to import struct X)

nicklockwood commented 10 months ago

@guillaumealgis I'm having some trouble reproducing this. Can you show me the whole file (or at least the first few lines up to an including some actual code)? I suspect the bug depends on what comes before or after the import.

EDIT: never mind, I've got it.

wmorgue commented 10 months ago

Temporary fix:

// swiftformat:disable enumnamespaces
import struct SwiftUI.Color

// some code...
nicklockwood commented 10 months ago

@pronebird @guillaumealgis @wmorgue fixed in 0.52.10