v/vlib/v/tests/anon_fn_redefinition_test.v

25 lines
405 B
V
Raw Normal View History

2021-02-25 12:16:35 +01:00
const default_logger = Example{}
struct Example {
structs []Another = [Another{}]
}
pub struct Another {
function fn (string) = fn (value string) {
println('$value')
}
}
pub fn (e Example) useless() string {
return 'ok'
}
fn test_anon_fn_redefinition() {
e1 := Example{}
assert e1.useless() == 'ok'
e2 := Example{}
assert e2.useless() == 'ok'
e3 := Example{}
assert e3.useless() == 'ok'
}