mirror of
https://github.com/vlang/v.git
synced 2025-09-13 09:25:45 -04:00
parent
f7187a7816
commit
a711e17f41
@ -1436,8 +1436,13 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
|||||||
arg_name := '_arg_expr_${fn_name}_0_${node.pos.pos}'
|
arg_name := '_arg_expr_${fn_name}_0_${node.pos.pos}'
|
||||||
g.write('/*af receiver arg*/' + arg_name)
|
g.write('/*af receiver arg*/' + arg_name)
|
||||||
} else {
|
} else {
|
||||||
if left_sym.kind == .array && node.left.is_auto_deref_var()
|
mut is_array := left_sym.kind == .array
|
||||||
&& is_array_method_first_last_repeat {
|
if !is_array && left_sym.kind == .alias {
|
||||||
|
unaliased_type := g.table.unaliased_type(left_type)
|
||||||
|
unaliased_sym := g.table.sym(unaliased_type)
|
||||||
|
is_array = unaliased_sym.kind == .array
|
||||||
|
}
|
||||||
|
if is_array && node.left.is_auto_deref_var() && is_array_method_first_last_repeat {
|
||||||
g.write('*')
|
g.write('*')
|
||||||
}
|
}
|
||||||
if node.left is ast.MapInit {
|
if node.left is ast.MapInit {
|
||||||
|
1
vlib/v/gen/c/testdata/alias_of_array_method_call.out
vendored
Normal file
1
vlib/v/gen/c/testdata/alias_of_array_method_call.out
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
&Option(Element{})
|
20
vlib/v/gen/c/testdata/alias_of_array_method_call.vv
vendored
Normal file
20
vlib/v/gen/c/testdata/alias_of_array_method_call.vv
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
struct Element {}
|
||||||
|
|
||||||
|
type ElementStack = []&Element
|
||||||
|
|
||||||
|
fn (mut stack ElementStack) pop_front() ?&Element {
|
||||||
|
return if stack.len > 0 {
|
||||||
|
val := stack.first()
|
||||||
|
stack.delete(0)
|
||||||
|
val
|
||||||
|
} else {
|
||||||
|
none
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
mut stack := ElementStack([]&Element{})
|
||||||
|
stack << &Element{}
|
||||||
|
a := stack.pop_front()
|
||||||
|
println(a)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user