Open seh opened 4 hours ago
I reckon the intended rewrite is switch i := strings.IndexByte(c, ' '); i {
which AFAICT would be correct. I'll have to check tomorrow if we emit a broken quickfix, or if this is an instance of https://github.com/golang/go/issues/63930.
Consider the following code, which I admit could use
strings.Cut
instead:My LSP implementation—gopls—reports the following:
It then offers a quick fix: "Replace with tagged switch". If I accept that suggestion, though, the resulting code is invalid, since I lose access to the "i" variable used in the return statement in the default case.
Note also the strange insertion of an extra "i" in the initial simple statement.
It seems that there are three things wrong here:
I don't know whether any of these are to blame on Emacs's lsp-mode that's making use of gopls.