mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix interface only declare with optional method (#10546)
This commit is contained in:
parent
500b48788e
commit
e8a1e9d88f
@ -1332,6 +1332,12 @@ fn (mut g Gen) stmt(node ast.Stmt) {
|
||||
ast.Import {}
|
||||
ast.InterfaceDecl {
|
||||
// definitions are sorted and added in write_types
|
||||
for method in node.methods {
|
||||
if method.return_type.has_flag(.optional) {
|
||||
// Register an optional if it's not registered yet
|
||||
g.register_optional(method.return_type)
|
||||
}
|
||||
}
|
||||
}
|
||||
ast.Module {
|
||||
// g.is_builtin_mod = node.name == 'builtin'
|
||||
|
8
vlib/v/tests/interface_only_decl_with_optional_test.v
Normal file
8
vlib/v/tests/interface_only_decl_with_optional_test.v
Normal file
@ -0,0 +1,8 @@
|
||||
interface Message {
|
||||
serialize() ?[]byte
|
||||
}
|
||||
|
||||
fn test_interface_only_decl_with_optional() {
|
||||
println('test interface')
|
||||
assert true
|
||||
}
|
Loading…
Reference in New Issue
Block a user