mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix maps
This commit is contained in:

committed by
Alexander Medvednikov

parent
0556f5fd4e
commit
916b13b286
@ -2303,10 +2303,12 @@ fn (p mut Parser) map_init() string {
|
||||
if !p.table.known_type(val_type) {
|
||||
p.error('map init unknown type "$val_type"')
|
||||
}
|
||||
typ := 'map_$val_type'
|
||||
p.register_map(typ)
|
||||
p.gen('new_map(1, sizeof($val_type))')
|
||||
p.check(.lcbr)
|
||||
p.check(.rcbr)
|
||||
return 'map_$val_type'
|
||||
return typ
|
||||
}
|
||||
|
||||
// [1,2,3]
|
||||
|
@ -543,11 +543,21 @@ fn type_default(typ string) string {
|
||||
}
|
||||
// Default values for other types are not needed because of mandatory initialization
|
||||
switch typ {
|
||||
case 'int': return '0'
|
||||
case 'string': return 'tos("", 0)'
|
||||
case 'void*': return '0'
|
||||
case 'byte*': return '0'
|
||||
case 'bool': return '0'
|
||||
case 'string': return 'tos("", 0)'
|
||||
case 'i8': return '0'
|
||||
case 'i16': return '0'
|
||||
case 'i32': return '0'
|
||||
case 'u8': return '0'
|
||||
case 'u16': return '0'
|
||||
case 'u32': return '0'
|
||||
case 'byte': return '0'
|
||||
case 'int': return '0'
|
||||
case 'rune': return '0'
|
||||
case 'f32': return '0.0'
|
||||
case 'f64': return '0.0'
|
||||
case 'byteptr': return '0'
|
||||
case 'voidptr': return '0'
|
||||
}
|
||||
return '{}'
|
||||
return ''
|
||||
|
Reference in New Issue
Block a user