checker: fix array_insert_or_prepend_short_struct_init (#8397)
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 {
|
pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
||||||
left_type := c.expr(call_expr.left)
|
left_type := c.expr(call_expr.left)
|
||||||
|
c.expected_type = left_type
|
||||||
is_generic := left_type.has_flag(.generic)
|
is_generic := left_type.has_flag(.generic)
|
||||||
call_expr.left_type = left_type
|
call_expr.left_type = left_type
|
||||||
// Set default values for .return_type & .receiver_type too,
|
// Set default values for .return_type & .receiver_type too,
|
||||||
|
|
|
@ -10,3 +10,16 @@ fn test_array_append_short_struct() {
|
||||||
println(pages)
|
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