-
Notifications
You must be signed in to change notification settings - Fork 39
imports: named import with metavariable should recognize unnamed import #2
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When trying to match all imports of a path, a patch that specified named imports, even with metavariables will turn unnamed imports into named imports.
Input
Patch:
@@
var foo, x identifier
@@
-import foo "example.com/foo-go.git"
+import foo "example.com/foo.git"
foo.xSource:
package whatever
import "example.com/foo-go.git"
func foo() {
foo.X()
}Expectation
package whatever
import "example.com/foo-go.git"
func foo() {
foo.X()
}
Reality
package whatever
import foo "example.com/foo-go.git"
func foo() {
foo.X()
}
Problem
This is undesirable; the foo metavariable should remember that the import was unnamed and reproduce that. Alternatively, we should provide a different means of matching imports that allows addressing both named and unnamed cases.
Workaround
For now, a workaround is to reproduce the patch as-is twice, once without the named import, once with:
@@
var x identifier
@@
-import "example.com/foo-go.git"
+import "example.com/foo.git"
foo.x
@@
var foo, x identifier
@@
-import foo "example.com/foo-go.git"
+import foo "example.com/foo.git"
foo.xReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working