mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix array_insert_or_prepend_short_struct_init (#8397)
This commit is contained in:
parent
56c4a36cd4
commit
26c06a56b7
@ -1239,6 +1239,7 @@ fn (mut c Checker) check_map_and_filter(is_map bool, elem_typ table.Type, call_e
|
||||
|
||||
pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
||||
left_type := c.expr(call_expr.left)
|
||||
c.expected_type = left_type
|
||||
is_generic := left_type.has_flag(.generic)
|
||||
call_expr.left_type = left_type
|
||||
// Set default values for .return_type & .receiver_type too,
|
||||
|
@ -8,5 +8,18 @@ fn test_array_append_short_struct() {
|
||||
contents: 3
|
||||
}
|
||||
println(pages)
|
||||
assert pages == [Page{ contents: 3}]
|
||||
assert pages == [Page{contents: 3}]
|
||||
}
|
||||
|
||||
struct Container {
|
||||
pub mut:
|
||||
name string
|
||||
}
|
||||
|
||||
fn test_array_insert_or_prepend_short_struct() {
|
||||
mut a := []Container{}
|
||||
a.prepend({name: 'a'})
|
||||
a.insert(0, {name: 'b'})
|
||||
println(a)
|
||||
assert a == [Container{name: 'b'}, Container{name: 'a'}]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user