gogrep icon indicating copy to clipboard operation
gogrep copied to clipboard

$*_ for import specs

Open quasilyte opened this issue 5 years ago • 2 comments

It seems that $*_ can't be used inside import spec:

import ($*_; "something/of/interest"; $*_)

The parsing error is:

cannot parse expr: 1:1: expected statement, found 'import'

If this is expected behavior, this issue can be closed.

quasilyte avatar Dec 24 '19 00:12 quasilyte

This is very similar to #48. Dollar expressions just get converted to gogrep_N identifiers, so that's not a valid import spec there.

mvdan avatar Dec 24 '19 01:12 mvdan

I think even if #32 becomes a preferred way to match something like this, it would be cool to have a way to match it via patterns as well.

To avoid another very similar issue, I'll add an additional case here:

type ($*_; $_ $x; $*_)

The type $_ $x pattern can't match type spec if it's inside ( ) group. Needed to make https://github.com/quasilyte/go-ruleguard/pull/43 more reliable.

quasilyte avatar Jan 09 '20 16:01 quasilyte