-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v.ast: allow for
fn f()&IAbc{return voidptr(0)}
with no additional …
…voidptr implicit conversions to compile
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
vlib/v/tests/interface_edge_cases/fn_returning_voidptr_casted_as_interface_test.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
interface IAbc { | ||
name string | ||
xyz() | ||
} | ||
|
||
fn f(i &IAbc) string { | ||
return '$i' | ||
} | ||
|
||
struct Abc { | ||
name string | ||
x int = 123 | ||
} | ||
|
||
fn (a Abc) xyz() {} | ||
|
||
fn resource__null() &IAbc { | ||
return voidptr(0) | ||
} | ||
|
||
fn test_fn_returning_voidptr_casted_as_interface_works() { | ||
pi := resource__null() | ||
assert f(pi) == '&IAbc(0)' | ||
} |