Yeah, this is a real problem. It's important that a developer can see locally (without much trouble) whether or not their code will violate the policy before they push up a PR and run a CI build.
Interesting. I imagine nobody was too happy with this and it would have been nice to have a little more flexibility in handling the unavoidable warnings, right?
The policy we would like is closer to "your PR must not add any new warnings, period" (but with a backdoor that can only be opened by a couple of people who ensure exceptions are accepted by our core team). Ideally, when we do choose to accept warnings we would have the option of suppressing the diagnostic for that instance if we choose to keep the list of reported warnings short or zero.
For sure! This is why it would be ideal to be able to suppress a warning in a specific location, or at least have it omitted from error promotion. This obviously creates a hole in -warnings-as-errors but there a number of reasonable approaches to addressing that. Short of the ability to do that, we may decide that we're willing to accept a specific class of warnings and / or rely on social pressure and code review to keep the unnecessary instances out of our codebase.
Right now, as soon as we have a single necessary warning -warnings-as-errors becomes useless. That is an extremely blunt instrument.
I wholeheartedly agree! However, this is not the current reality and I don't see evidence of it becoming a priority. Even if the language did fill this gap there it is not likely to address deprecations or compiler bugs which force warnings on us. I'd rather not have to wait until the language is sufficiently mature to solve the issue this way (although I would like to see this happen eventually). As far as I can tell we're still years away from reaching this level of maturity.
I know this has been stated before and the Swift team is very sensitive to this issue, but I don't think it is completely accurate in this case. Promoting warnings to errors does not change anything about the semantics of the language, it only changes how issues are reported by the compiler. It's completely reasonable for a team to want to define policies around how different kinds of issues are handled.
Is -warnings-as-errors a dialect? If so, why is that flag acceptable? If not, why does finer-grained control produce dialects when that is not a dialect?
Further, if you consider the context in which Swift is often used you will find that SwiftLint is extremely popular. The configurability (including custom rules!) of this tool has been an incredible asset to our team. I haven't heard any complaints about SwiftLint creating language dialects. Perhaps the community's experience with a tool like this is sufficient to revisit the idea that simply promoting a warning to an error creates a language dialect.
+1. I understand if a solution has just not been a priority yet, but my impression is that there is resistance to solving this problem, especially because of the "language dialect" issue. I have not yet seen anything resembling a sound argument for the current state of a blunt all-or-nothing -warnings-as-errors (paired with the eventual capability to silence all potentially spurious warnings) as a final solution. (Again, I understand if this is simply not a priority yet, but I think it should be soon - Swift is used by some very large teams these days)
Theoretically they aren't, but pragmatically they are a tool that helps a large team evolve / refactor a large codebase incrementally. I don't think we should have to choose between using this tool and using -warnings-as-errors.
I want to emphasize that I don't have any strong opinions about how this problem should be solved but I do think that it is crucial to provide more flexibility in handling warnings and deprecation than we currently have available.