diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 6b9fab0c77597b..cdfa38554bd220 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1056,7 +1056,7 @@ fn (mut c Checker) type_implements(typ ast.Type, interface_type ast.Type, pos to inter_sym.methods } // voidptr is an escape hatch, it should be allowed to be passed - if utyp != ast.voidptr_type && utyp != ast.nil_type { + if utyp != ast.voidptr_type && utyp != ast.nil_type && utyp != ast.none_type { mut are_methods_implemented := true // Verify methods diff --git a/vlib/v/tests/option_interface_test.v b/vlib/v/tests/option_interface_test.v new file mode 100644 index 00000000000000..d1cbea7742abcb --- /dev/null +++ b/vlib/v/tests/option_interface_test.v @@ -0,0 +1,18 @@ +interface TestIntf { + test() +} + +struct TestStruct { + ti ?TestIntf +} + +fn TestStruct.new() TestStruct { + return TestStruct{ + ti: none + } +} + +fn test_main() { + t := TestStruct.new() + assert t.ti == none +}