swiftcsv / SwiftCSV

CSV parser for Swift
MIT License
947 stars 190 forks source link

Enumerated Ambiguous Use #124

Open MattTimmons opened 1 year ago

MattTimmons commented 1 year ago

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?

dagronf commented 1 year ago

@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 ...
DivineDominion commented 1 year ago

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 👍

chezchez commented 10 months ago

Thanks dagronf! That workaround did it for me.