Closed alistra closed 3 weeks ago
@alistra thanks for the report. I've never actually seen single-element tuples in action (though I was aware they'd been added recently), and I didn't know that they could be used this way!
It's not really clear what the right solution is here since there doesn't appear to be an equivalent syntax for for loop pattern matching. Probably it's safest just to detect this scenario and disable the preferForLoop
rule in these cases.
cc: @calda
Agreed, we can disable the preferForLoop rule if any of the arguments have a type that is a tuple with labeled arguments. I can post a fix for this.
edit: Oh I see, we aren't renaming the tuple arguments or anything, the output for (header, value) in dict
is just totally wrong. Should be an easy fix to make it just use for header in dict
.
@calda seems to work like you say.
let dict: [String: String] = ["a": "b"]
for header in dict {
print(header.key)
print(header.value)
}
is a good result. Question is should the formatter always emit .key
and .value
or stick to labels in the original code
I saw the implementation - it uses the custom labels, but compiler emits a warning - seems great.
@alistra fix landed in 0.54.0
When I have a file with named tuple destructuring in closure argument like this:
and I try to format it using
without any configuration file
I get this error when compiling
because the code formats to this
and realistically should either format to this:
or not be changed at all.