diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index e0dbc0fd2660a1..398cee24d40e0d 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -685,8 +685,7 @@ pub: is_hidden bool // interface first arg on_newline bool // whether the argument starts on a new line pub mut: - typ Type - comments []Comment + typ Type } pub fn (p &Param) specifier() string { diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index 6cdb08791fdf1c..0ff911df5f01f5 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -138,7 +138,6 @@ pub fn (t &Table) stringify_fn_decl(node &FnDecl, cur_mod string, m2a map[string fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_mod string, m2a map[string]string) { mut add_para_types := true - mut is_wrap_needed := false if node.generic_names.len > 0 { if node.is_method { sym := t.sym(node.params[0].typ) @@ -175,22 +174,6 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m } is_last_param := i == node.params.len - 1 is_type_only := param.name == '' - should_add_type := true // is_last_param || is_type_only || node.params[i + 1].typ != param.typ || - // (node.is_variadic && i == node.params.len - 2) - pre_comments := param.comments.filter(it.pos.pos < param.pos.pos) - if pre_comments.len > 0 { - if i == 0 { - is_wrap_needed = true - f.write_string('\n\t') - } - write_comments(pre_comments, mut f) - if !f.last_n(1)[0].is_space() { - f.write_string(' ') - } - } - if is_wrap_needed { - f.write_string('\t') - } if param.on_newline { f.write_string('\n\t') pline++ @@ -228,15 +211,13 @@ fn (t &Table) stringify_fn_after_name(node &FnDecl, mut f strings.Builder, cur_m } s = util.no_cur_mod(s, cur_mod) s = shorten_full_name_based_on_aliases(s, m2a) - if should_add_type { - if !is_type_only { - f.write_string(' ') - } - if node.is_variadic && is_last_param { - f.write_string('...') - } - f.write_string(s) + if !is_type_only { + f.write_string(' ') + } + if node.is_variadic && is_last_param { + f.write_string('...') } + f.write_string(s) } if !is_last_param { f.write_string(',') diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 12349175a9fe82..9b43ca77518771 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -899,7 +899,6 @@ fn (mut p Parser) fn_params() ([]ast.Param, bool, bool) { if types_only { mut param_no := 1 for p.tok.kind != .rpar { - mut comments := p.eat_comments() if p.tok.kind == .eof { p.error_with_pos('expecting `)`', p.tok.pos()) return []ast.Param{}, false, false @@ -963,7 +962,6 @@ fn (mut p Parser) fn_params() ([]ast.Param, bool, bool) { p.error_with_pos('expecting `)`', p.prev_tok.pos()) return []ast.Param{}, false, false } - comments << p.eat_comments() if p.tok.kind == .comma { if is_variadic { @@ -983,7 +981,6 @@ fn (mut p Parser) fn_params() ([]ast.Param, bool, bool) { is_mut: is_mut typ: param_type type_pos: type_pos - comments: comments on_newline: prev_param_newline != pos.line_nr } prev_param_newline = pos.line_nr @@ -995,7 +992,6 @@ fn (mut p Parser) fn_params() ([]ast.Param, bool, bool) { } } else { for p.tok.kind != .rpar { - mut comments := p.eat_comments() if p.tok.kind == .eof { p.error_with_pos('expecting `)`', p.tok.pos()) return []ast.Param{}, false, false @@ -1008,7 +1004,6 @@ fn (mut p Parser) fn_params() ([]ast.Param, bool, bool) { } mut param_pos := [p.tok.pos()] name := p.check_name() - comments << p.eat_comments() mut param_names := [name] if name != '' && p.fn_language == .v && name[0].is_capital() { p.error_with_pos('parameter name must not begin with upper case letter (`${param_names[0]}`)', @@ -1082,7 +1077,6 @@ fn (mut p Parser) fn_params() ([]ast.Param, bool, bool) { // derive flags, however nr_muls only needs to be set on the array elem type, so clear it on the arg type typ = ast.new_type(p.table.find_or_register_array(typ)).derive(typ).set_nr_muls(0).set_flag(.variadic) } - comments << p.eat_comments() for i, para_name in param_names { alanguage := p.table.sym(typ).language if alanguage != .v { @@ -1096,7 +1090,6 @@ fn (mut p Parser) fn_params() ([]ast.Param, bool, bool) { is_shared: is_shared typ: typ type_pos: type_pos[i] - comments: comments on_newline: prev_param_newline != param_pos[i].line_nr } prev_param_newline = param_pos[i].line_nr