1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: variadic for in loop

This commit is contained in:
Joe Conigliaro
2020-03-24 19:42:16 +11:00
parent 309a905409
commit 3d2fafa580
2 changed files with 28 additions and 11 deletions

View File

@@ -414,7 +414,11 @@ pub fn (t mut Table) add_placeholder_type(name string) int {
[inline]
pub fn (t &Table) value_type(typ Type) Type {
typ_sym := t.get_type_symbol(typ)
if typ_sym.kind == .array {
if type_is_variadic(typ) {
// ...string => string
return type_clear_extra(typ)
}
else if typ_sym.kind == .array {
// Check index type
info := typ_sym.info as Array
return info.elem_type
@@ -435,10 +439,6 @@ pub fn (t &Table) value_type(typ Type) Type {
// bytes[0] is a byte, not byte*
return type_deref(typ)
}
else if type_is_variadic(typ) {
// ...string => string
return type_clear_extra(typ)
}
else {
// TODO: remove when map_string is removed
if typ_sym.name == 'map_string' {