gotools/refactor/eg/testdata/expr_type_mismatch.txtar



-- go.mod --
module example.com
go 1.18

-- template/template.go --
package template

import (
	"crypto/x509"
	"fmt"
)

// This test demonstrates a false negative: according to the language
// rules this replacement should be ok, but types.Assignable doesn't work
// in the expected way (elementwise assignability) for tuples.
// Perhaps that's even a type-checker bug?
const shouldFail = "(n int, err error) is not a safe replacement for (key any, err error)"

func before() (interface{}, error) { return x509.ParsePKCS8PrivateKey(nil) }
func after() (interface{}, error)  { return fmt.Print() }