Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cgen: fix error for generics struct that parent has str to string (#1…
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
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
36 changes: 36 additions & 0 deletions
36
vlib/v/tests/generics_struct_parent_has_str_to_string_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,36 @@ | ||
import datatypes | ||
|
||
const ( | ||
w = 64 | ||
h = 32 | ||
) | ||
|
||
interface Display { | ||
mut: | ||
pixel(x int, y int, val bool) | ||
clear() | ||
refresh() | ||
} | ||
|
||
struct Vm { | ||
mut: | ||
display Display | ||
stack datatypes.Stack<u16> | ||
} | ||
|
||
struct Pattern { | ||
pattern []byte | ||
handler fn (mut m Vm) | ||
} | ||
|
||
fn new_pattern(pattern string, handler fn (mut m Vm)) Pattern { | ||
return Pattern{pattern.runes().map(byte('0x$it'.int())), handler} | ||
} | ||
|
||
fn test_generics_struct_parent_has_str_to_string() { | ||
p := new_pattern('00E0', fn (mut m Vm) { | ||
println(m) | ||
}) | ||
println(p) | ||
assert true | ||
} |