1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
Felipe Pena 2023-08-09 18:40:57 -03:00
parent 7d84ddfa65
commit 20ef2354e7
2 changed files with 8 additions and 3 deletions

View File

@ -636,7 +636,8 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
if is_decl { if is_decl {
g.writeln(';') g.writeln(';')
} }
} else if !var_type.has_flag(.option_mut_param_t) && !g.is_arraymap_set && !str_add && !op_overloaded { } else if !var_type.has_flag(.option_mut_param_t) && !g.is_arraymap_set && !str_add
&& !op_overloaded {
g.write(' ${op} ') g.write(' ${op} ')
} else if str_add || op_overloaded { } else if str_add || op_overloaded {
g.write(', ') g.write(', ')

View File

@ -186,7 +186,11 @@ fn (mut g Gen) gen_str_for_option(typ ast.Type, styp string, str_fn_name string)
g.auto_str_funcs.writeln('string indent_${str_fn_name}(${styp} it, int indent_count) {') g.auto_str_funcs.writeln('string indent_${str_fn_name}(${styp} it, int indent_count) {')
g.auto_str_funcs.writeln('\tstring res;') g.auto_str_funcs.writeln('\tstring res;')
g.auto_str_funcs.writeln('\tif (it.state == 0) {') g.auto_str_funcs.writeln('\tif (it.state == 0) {')
deref := if typ.is_ptr() && !typ.has_flag(.option_mut_param_t) { '**(${sym.cname}**)&' } else { '*(${sym.cname}*)' } deref := if typ.is_ptr() && !typ.has_flag(.option_mut_param_t) {
'**(${sym.cname}**)&'
} else {
'*(${sym.cname}*)'
}
if sym.kind == .string { if sym.kind == .string {
if typ.nr_muls() > 1 { if typ.nr_muls() > 1 {
g.auto_str_funcs.writeln('\t\tres = ptr_str(*(${sym.cname}**)&it.data);') g.auto_str_funcs.writeln('\t\tres = ptr_str(*(${sym.cname}**)&it.data);')