/
githubmirror
/
go
Обзор
Документация
Войти
/
githubmirror
/
go
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
go1.26.2
test/interface/pointer.go
37 строк
758 B
Robert Griesemer
go/types, types2: more systematic use of Checker.use und useLHS
28 мар 2023, 17:28
28 мар 2023, 17:28
abf9b11
Код
Авторство
О чём код?
// errorcheck // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Test that interface{M()} = *interface{M()} produces a compiler error. // Does not compile. package main type Inst interface { Next() *Inst } type Regexp struct { code []Inst start Inst } type Start struct { foo *Inst } func (start *Start) Next() *Inst { return nil } func AddInst(Inst) *Inst { print("ok in addinst\n") return nil } func main() { print("call addinst\n") var _ Inst = AddInst(new(Start)) // ERROR "pointer to interface|incompatible type" print("return from addinst\n") var _ *Inst = new(Start) // ERROR "pointer to interface|incompatible type" }