mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ci: compile golang_builder.v without warnings (fix v -prod build-tools
)
This commit is contained in:
parent
2bcbd0b636
commit
b47d35a0bb
@ -1107,7 +1107,7 @@ pub fn (mut f Gen) interface_decl(node ast.InterfaceDecl) {
|
||||
|
||||
pub fn (mut f Gen) interface_field(field ast.StructField) {
|
||||
mut ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias))
|
||||
end_pos := field.pos.pos + field.pos.len
|
||||
// end_pos := field.pos.pos + field.pos.len
|
||||
f.write('\t$field.name $ft')
|
||||
f.writeln('')
|
||||
f.mark_types_import_as_used(field.typ)
|
||||
@ -1278,7 +1278,7 @@ pub fn (mut f Gen) fn_type_decl(node ast.FnTypeDecl) {
|
||||
|
||||
pub fn (mut f Gen) sum_type_decl(node ast.SumTypeDecl) {
|
||||
f.attrs(node.attrs)
|
||||
start_pos := f.out.len
|
||||
// start_pos := f.out.len
|
||||
if node.is_pub {
|
||||
f.write('pub ')
|
||||
}
|
||||
@ -1339,16 +1339,16 @@ pub fn (mut f Gen) array_init(node ast.ArrayInit) {
|
||||
// `[1,2,3]`
|
||||
sym := f.table.sym(node.typ)
|
||||
f.write('$sym.name{')
|
||||
mut inc_indent := false
|
||||
// mut inc_indent := false
|
||||
mut last_line_nr := node.pos.line_nr // to have the same newlines between array elements
|
||||
if node.pre_cmnts.len > 0 {
|
||||
if node.pre_cmnts[0].pos.line_nr > last_line_nr {
|
||||
f.writeln('')
|
||||
}
|
||||
}
|
||||
mut set_comma := false
|
||||
for i, expr in node.exprs {
|
||||
pos := expr.pos()
|
||||
// mut set_comma := false
|
||||
for expr in node.exprs {
|
||||
// pos := expr.pos()
|
||||
f.expr(expr)
|
||||
f.write(',')
|
||||
}
|
||||
@ -1395,8 +1395,7 @@ pub fn (mut f Gen) at_expr(node ast.AtExpr) {
|
||||
}
|
||||
|
||||
pub fn (mut f Gen) call_expr(node ast.CallExpr) {
|
||||
for arg in node.args {
|
||||
}
|
||||
// for arg in node.args {}
|
||||
mut is_method_newline := false
|
||||
if node.is_method {
|
||||
if node.name in ['map', 'filter', 'all', 'any'] {
|
||||
@ -1598,10 +1597,10 @@ pub fn (mut f Gen) ident(node ast.Ident) {
|
||||
} else if node.kind == .blank_ident {
|
||||
f.write('_')
|
||||
} else {
|
||||
mut is_local := false
|
||||
// mut is_local := false
|
||||
if !isnil(f.fn_scope) {
|
||||
if _ := f.fn_scope.find_var(node.name) {
|
||||
is_local = true
|
||||
// is_local = true
|
||||
}
|
||||
}
|
||||
name := f.short_module(node.name)
|
||||
@ -1616,8 +1615,8 @@ pub fn (mut f Gen) if_expr(node ast.IfExpr) {
|
||||
&& branch_is_single_line(node.branches[0]) && branch_is_single_line(node.branches[1])
|
||||
&& (node.is_expr || f.is_assign || f.is_struct_init || f.single_line_fields)
|
||||
f.single_line_if = is_ternary
|
||||
start_pos := f.out.len
|
||||
start_len := f.line_len
|
||||
// start_pos := f.out.len
|
||||
// start_len := f.line_len
|
||||
for {
|
||||
for i, branch in node.branches {
|
||||
if i == 0 {
|
||||
@ -1706,8 +1705,8 @@ pub fn (mut f Gen) infix_expr(node ast.InfixExpr) {
|
||||
if node.op == .left_shift {
|
||||
f.is_assign = true // To write ternary if on a single line
|
||||
}
|
||||
start_pos := f.out.len
|
||||
start_len := f.line_len
|
||||
// start_pos := f.out.len
|
||||
// start_len := f.line_len
|
||||
f.expr(node.left)
|
||||
is_one_val_array_init := node.op in [.key_in, .not_in] && node.right is ast.ArrayInit
|
||||
&& (node.right as ast.ArrayInit).exprs.len == 1
|
||||
@ -1792,8 +1791,8 @@ fn (mut f Gen) write_splitted_infix(conditions []string, penalties []int, ignore
|
||||
}
|
||||
for i, cnd in conditions {
|
||||
c := cnd.trim_space()
|
||||
is_paren_expr := (c[0] == `(` || (c.len > 5 && c[3] == `(`)) && c.ends_with(')')
|
||||
final_len := ((f.indent + 1) * 4) + c.len
|
||||
// is_paren_expr := (c[0] == `(` || (c.len > 5 && c[3] == `(`)) && c.ends_with(')')
|
||||
// final_len := ((f.indent + 1) * 4) + c.len
|
||||
if i == 0 {
|
||||
f.remove_new_line()
|
||||
}
|
||||
@ -1997,8 +1996,8 @@ pub fn (mut f Gen) or_expr(node ast.OrExpr) {
|
||||
} else if node.stmts.len == 1 && stmt_is_single_line(node.stmts[0]) {
|
||||
// the control stmts (return/break/continue...) print a newline inside them,
|
||||
// so, since this'll all be on one line, trim any possible whitespace
|
||||
str := f.node_str(node.stmts[0]).trim_space()
|
||||
single_line := ' or { $str }'
|
||||
// str := f.node_str(node.stmts[0]).trim_space()
|
||||
// single_line := ' or { $str }'
|
||||
}
|
||||
// Make it multiline if the blocks has at least two stmts
|
||||
// or a single line would be too long
|
||||
|
@ -27,12 +27,12 @@ pub fn (mut f Gen) struct_decl(node ast.StructDecl) {
|
||||
return
|
||||
}
|
||||
mut field_types := []string{cap: node.fields.len}
|
||||
for i, field in node.fields {
|
||||
for field in node.fields {
|
||||
ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias))
|
||||
field_types << ft
|
||||
attrs_len := inline_attrs_len(field.attrs)
|
||||
end_pos := field.pos.pos + field.pos.len
|
||||
mut comments_len := 0 // Length of comments between field name and type
|
||||
// attrs_len := inline_attrs_len(field.attrs)
|
||||
// end_pos := field.pos.pos + field.pos.len
|
||||
// mut comments_len := 0 // Length of comments between field name and type
|
||||
// field_aligns.add_info(comments_len + field.name.len, ft.len, field.pos.line_nr)
|
||||
if field.has_default_expr {
|
||||
// default_expr_aligns.add_info(attrs_len, field_types[i].len, field.pos.line_nr,
|
||||
@ -45,9 +45,9 @@ pub fn (mut f Gen) struct_decl(node ast.StructDecl) {
|
||||
styp := f.table.type_to_str_using_aliases(embed.typ, f.mod2alias)
|
||||
f.writeln('\t$styp')
|
||||
}
|
||||
mut field_align_i := 0
|
||||
mut comment_align_i := 0
|
||||
mut default_expr_align_i := 0
|
||||
// mut field_align_i := 0
|
||||
// mut comment_align_i := 0
|
||||
// mut default_expr_align_i := 0
|
||||
mut inc_indent := false // for correct indents with multi line default exprs
|
||||
for i, field in node.fields {
|
||||
if i == node.mut_pos {
|
||||
@ -72,10 +72,10 @@ pub fn (mut f Gen) struct_decl(node ast.StructDecl) {
|
||||
f.writeln('')
|
||||
}
|
||||
}
|
||||
end_pos := field.pos.pos + field.pos.len
|
||||
// end_pos := field.pos.pos + field.pos.len
|
||||
volatile_prefix := if field.is_volatile { 'volatile ' } else { '' }
|
||||
f.write('\t$volatile_prefix$field.name ')
|
||||
before_len := f.line_len
|
||||
// before_len := f.line_len
|
||||
// mut field_align := field_aligns[field_align_i]
|
||||
// if field_align.line_nr < field.pos.line_nr {
|
||||
// field_align_i++
|
||||
@ -84,7 +84,7 @@ pub fn (mut f Gen) struct_decl(node ast.StructDecl) {
|
||||
// f.write(strings.repeat(` `, field_align.max_len - field.name.len - comments_len))
|
||||
f.write(field_types[i])
|
||||
f.mark_types_import_as_used(field.typ)
|
||||
attrs_len := inline_attrs_len(field.attrs)
|
||||
// attrs_len := inline_attrs_len(field.attrs)
|
||||
has_attrs := field.attrs.len > 0
|
||||
if has_attrs {
|
||||
// f.write(strings.repeat(` `, field_align.max_type_len - field_types[i].len))
|
||||
@ -163,7 +163,7 @@ pub fn (mut f Gen) struct_init(node ast.StructInit) {
|
||||
f.write(' ')
|
||||
}
|
||||
}
|
||||
fields_start := f.out.len
|
||||
// fields_start := f.out.len
|
||||
fields_loop: for {
|
||||
if !single_line_fields {
|
||||
if use_short_args && f.out[f.out.len - 1] == ` ` {
|
||||
|
Loading…
Reference in New Issue
Block a user