SwiftCSV icon indicating copy to clipboard operation
SwiftCSV copied to clipboard

Enumerated Ambiguous Use

Open MattTimmons opened this issue 2 years ago • 3 comments
trafficstars

Xcode 14.3 is throwing Ambiguous use of 'enumerateAsArray'

with

do {
            // As a string, guessing the delimiter
            let csv: CSV = try CSV<Enumerated>(string: "id,name,age\n1,Alice,18")

            csv.enumerateAsArray { array in
                print(array.first)
            }
            
        } catch let parseError as CSVParseError {
            // Catch errors from parsing invalid CSV
        } catch {
            // Catch errors from trying to load files
        }

Ideas?

MattTimmons avatar Apr 05 '23 16:04 MattTimmons

@MattTimmons

There are two enumerateAsArray calls that both have all parameters as default or optional. As a result, calling enumerateAsArray with no parameters as per the README example won't be able to determine which variant to call, as they both end up with the same signature.

My workaround was to use

try csv.enumerateAsArray(rowLimit: Int.max) { array in ...

dagronf avatar Jun 03 '23 05:06 dagronf

Thanks for spotting this, folks! @dagronf @MattTimmons I'd be happy to merge a PR that addresses this public API issue in a sensible way 👍

DivineDominion avatar Aug 06 '23 16:08 DivineDominion

Thanks dagronf! That workaround did it for me.

chezchez avatar Oct 18 '23 10:10 chezchez