Incorrect use of = in function parameters

It’s not so much about (performance) cost but overall complexity. Implementation wouldn’t be hard to do, but linting is always about style and that’s highly subjective. The compiler’s formatter tool for example represents very basic styling rules that can be expected to be followed by the vast majority of Crystal projects. But everything beyond that is really hard to do because finding a consensus is almost impossible. That’s why linting is better suited as a stand-alone tool, allowing a good amount of flexibility to adjust to one’s liking.

So the main action point here is IMO to just recommend using ameba (or any linter, in case there are others).

Regarding the compiler, the only option that sounds somewhat reasonable to me is making assignments in method call arguments invalid (as mentioned in Named arguments usage ambiguity). Considering this is a common pitfall (I remember falling into as well, a long time ago) and there’s probably not a really striking reason to allow this, it might be better to just make it an error.

4 Likes