mirror of
https://github.com/vlang/v.git
synced 2025-09-18 11:56:57 -04:00
checker: add test for interface embedding and interface with erroneous implementation (test related to #21030) (#21033)
This commit is contained in:
parent
3d64f9e465
commit
6809c67805
@ -0,0 +1,9 @@
|
||||
vlib/v/checker/tests/struct_init_with_iface_embed_iface_with_incorrect_method_impl_ref_field_err.vv:21:3: error: `&Stream` incorrectly implements method `read` of interface `Refresher`: expected return type `!int`
|
||||
19 | s := &Stream{}
|
||||
20 | _ := &Server{
|
||||
21 | refresher: s
|
||||
| ~~~~~~~~~~~~
|
||||
22 | }
|
||||
23 | }
|
||||
Details: main.Refresher has `fn read(x main.Refresher, buf []u8) !int`
|
||||
main.Stream has `fn read(a main.Stream, buf []u8)`
|
@ -0,0 +1,23 @@
|
||||
interface Refresher {
|
||||
Reader
|
||||
}
|
||||
|
||||
interface Reader {
|
||||
read(buf []u8) !int
|
||||
}
|
||||
|
||||
struct Server {
|
||||
refresher Refresher
|
||||
}
|
||||
|
||||
struct Stream {}
|
||||
|
||||
// Implementation is missing the return type.
|
||||
fn (a Stream) read(buf []u8) {}
|
||||
|
||||
fn test_struct_init_with_interface_field() {
|
||||
s := &Stream{}
|
||||
_ := &Server{
|
||||
refresher: s
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user