mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix error for array_of_aliases.pop() (#14861)
This commit is contained in:
parent
34517c340d
commit
1af94c7edf
@ -1165,8 +1165,7 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
|
||||
c.error('cannot $method_name `$arg_sym.name` to `$left_sym.name`', arg_expr.pos())
|
||||
}
|
||||
} else if final_left_sym.info is ast.Array && method_name in ['first', 'last', 'pop'] {
|
||||
node.return_type = final_left_sym.info.elem_type
|
||||
return node.return_type
|
||||
return c.array_builtin_method_call(mut node, left_type, final_left_sym)
|
||||
} else if c.pref.backend.is_js() && left_sym.name.starts_with('Promise<')
|
||||
&& method_name == 'wait' {
|
||||
info := left_sym.info as ast.Struct
|
||||
|
17
vlib/v/tests/array_of_alias_pop_test.v
Normal file
17
vlib/v/tests/array_of_alias_pop_test.v
Normal file
@ -0,0 +1,17 @@
|
||||
[heap]
|
||||
struct Attribute {
|
||||
mut:
|
||||
name string
|
||||
value string
|
||||
}
|
||||
|
||||
type AttributeStack = []&Attribute
|
||||
|
||||
fn test_array_of_alias_pop() {
|
||||
mut stack := AttributeStack([]&Attribute{})
|
||||
stack << &Attribute{'foo', 'bar'}
|
||||
ret := stack.pop()
|
||||
println(ret)
|
||||
assert ret.name == 'foo'
|
||||
assert ret.value == 'bar'
|
||||
}
|
Loading…
Reference in New Issue
Block a user