mirror of
https://github.com/vlang/v.git
synced 2025-09-09 15:27:05 -04:00
This commit is contained in:
parent
8b5ee60275
commit
056998a42a
@ -4694,8 +4694,8 @@ fn (mut c Checker) mark_as_referenced(mut node ast.Expr, as_interface bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
type_sym := c.table.sym(obj.typ.set_nr_muls(0))
|
type_sym := c.table.sym(obj.typ.set_nr_muls(0))
|
||||||
if obj.is_stack_obj && !type_sym.is_heap() && !c.pref.translated
|
if obj.is_stack_obj && !type_sym.is_heap() && !type_sym.is_int()
|
||||||
&& !c.file.is_translated {
|
&& !c.pref.translated && !c.file.is_translated {
|
||||||
suggestion := if type_sym.kind == .struct {
|
suggestion := if type_sym.kind == .struct {
|
||||||
'declaring `${type_sym.name}` as `@[heap]`'
|
'declaring `${type_sym.name}` as `@[heap]`'
|
||||||
} else {
|
} else {
|
||||||
|
12
vlib/v/tests/interfaces/interface_int_test.v
Normal file
12
vlib/v/tests/interfaces/interface_int_test.v
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
interface Value {}
|
||||||
|
|
||||||
|
fn test_main() {
|
||||||
|
mut a := []string{len: 10}
|
||||||
|
mut v := []Value{}
|
||||||
|
for i := 0; i < a.len; i++ {
|
||||||
|
v << i
|
||||||
|
}
|
||||||
|
assert v[0] == Value(0)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user