forked from golang/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/refactor: undo variadic elimination during substitution
When substituting an argument that has been synthetically packed into a composite literal expression, into the varadic argument of a call, we can undo the variadic elimination and unpack the arguments into the call. Fixes golang/go#63717 Fixes golang/go#69441 Change-Id: I8a48664b2e6486ca492e03e233b8600473e9d1a9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/629136 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
- Loading branch information
Showing
5 changed files
with
105 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
This test checks that variadic elimination does not cause a semantic change due | ||
to creation of a non-nil empty slice instead of a nil slice due to missing | ||
variadic arguments. | ||
|
||
-- go.mod -- | ||
module testdata | ||
go 1.12 | ||
|
||
-- foo/foo.go -- | ||
package foo | ||
import "fmt" | ||
|
||
func F(is ...int) { | ||
if is == nil { | ||
fmt.Println("is is nil") | ||
} else { | ||
fmt.Println("is is not nil") | ||
} | ||
} | ||
|
||
func G(is ...int) { F(is...) } | ||
|
||
func main() { | ||
G() //@ inline(re"G", G) | ||
} | ||
|
||
-- G -- | ||
package foo | ||
|
||
import "fmt" | ||
|
||
func F(is ...int) { | ||
if is == nil { | ||
fmt.Println("is is nil") | ||
} else { | ||
fmt.Println("is is not nil") | ||
} | ||
} | ||
|
||
func G(is ...int) { F(is...) } | ||
|
||
func main() { | ||
F() //@ inline(re"G", G) | ||
} |