New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SI-6276 Exclude var from trivial recursion warning #5391
Conversation
`var x: X = x` is the new `var x: X = _`. Unlike explicitly setting a default, it preserves any value that was set earlier during initialization.
I'm not sure how I feel about this... |
This must have come up on gitter or SO. In fact, I suddenly recall you wanted to eliminate underscore syntax? Maybe that was the context. |
ah, the discussion about as for the "preserves any value that was set earlier during initialization" part, that gives my hives the heebie jeebies, or is that the other way around? indeed
but is there a point to reducing this from 2 warnings to 1? I think it'd rather it printed 10 warnings. maybe you've spent longer thinking about than I have and you actually have a case, but if so, I'm asking you to state that case. what's an example of code that it's actually good not to issue this warning for? |
It can be useful to stash a value somewhere for debugging purposes, that is, to be read with a debugger. With #5402
The warning about private setter should suggest using a val, so I broke that message. (Edit: actually it always worked like that, only local vars get the val prompt.) |
further thoughts or opinions on this, anyone? |
I'm not anyone, but re-reading it again, it's pretty funny.
|
I also don't feel like |
I'm not sensing a lot of enthusiasm for this one. If the main use case is for debugging purposes, wouldn't it be desirable to have a warning remind you to remind that debug line before you submit your PR? Happy to reopen if someone feels strongly about getting this in. |
Thanks, I'll reopen when attempts to squash the underscore initializer break down in tears. The syntax from the dotty implicit args issue might work, namely, |
var x: X = x
is the newvar x: X = _
.Unlike explicitly setting a default, it preserves any value
that was set earlier during initialization.