fmt: fix formatting of anon args (#6545)
parent
51987e17df
commit
fd88bfbac8
|
@ -28,7 +28,7 @@ mut:
|
||||||
|
|
||||||
fn C.uname(name voidptr) int
|
fn C.uname(name voidptr) int
|
||||||
|
|
||||||
fn C.symlink(arg_1, arg_2 charptr) int
|
fn C.symlink(charptr, charptr) int
|
||||||
|
|
||||||
pub fn uname() Uname {
|
pub fn uname() Uname {
|
||||||
mut u := Uname{}
|
mut u := Uname{}
|
||||||
|
|
18
vlib/pg/pg.v
18
vlib/pg/pg.v
|
@ -30,23 +30,23 @@ pub:
|
||||||
|
|
||||||
fn C.PQconnectdb(a byteptr) &C.PGconn
|
fn C.PQconnectdb(a byteptr) &C.PGconn
|
||||||
|
|
||||||
fn C.PQerrorMessage(arg_1 voidptr) byteptr
|
fn C.PQerrorMessage(voidptr) byteptr
|
||||||
|
|
||||||
fn C.PQgetvalue(arg_1 voidptr, arg_2, arg_3 int) byteptr
|
fn C.PQgetvalue(voidptr, int, int) byteptr
|
||||||
|
|
||||||
fn C.PQstatus(arg_1 voidptr) int
|
fn C.PQstatus(voidptr) int
|
||||||
|
|
||||||
fn C.PQntuples(arg_1 voidptr) int
|
fn C.PQntuples(voidptr) int
|
||||||
|
|
||||||
fn C.PQnfields(arg_1 voidptr) int
|
fn C.PQnfields(voidptr) int
|
||||||
|
|
||||||
fn C.PQexec(arg_1 voidptr) voidptr
|
fn C.PQexec(voidptr) voidptr
|
||||||
|
|
||||||
fn C.PQexecParams(arg_1 voidptr) voidptr
|
fn C.PQexecParams(voidptr) voidptr
|
||||||
|
|
||||||
fn C.PQclear(arg_1 voidptr) voidptr
|
fn C.PQclear(voidptr) voidptr
|
||||||
|
|
||||||
fn C.PQfinish(arg_1 voidptr)
|
fn C.PQfinish(voidptr)
|
||||||
|
|
||||||
// connect makes a new connection to the database server using
|
// connect makes a new connection to the database server using
|
||||||
// the parameters from the `Config` structure, returning
|
// the parameters from the `Config` structure, returning
|
||||||
|
|
|
@ -64,7 +64,8 @@ pub fn (node &FnDecl) stringify(t &table.Table, cur_mod string) string {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
is_last_arg := i == node.params.len - 1
|
is_last_arg := i == node.params.len - 1
|
||||||
should_add_type := is_last_arg || node.params[i + 1].typ != arg.typ ||
|
is_type_only := arg.name == ''
|
||||||
|
should_add_type := is_last_arg || is_type_only || node.params[i + 1].typ != arg.typ ||
|
||||||
(node.is_variadic && i == node.params.len - 2)
|
(node.is_variadic && i == node.params.len - 2)
|
||||||
if arg.is_mut {
|
if arg.is_mut {
|
||||||
f.write(arg.typ.share().str() + ' ')
|
f.write(arg.typ.share().str() + ' ')
|
||||||
|
@ -79,11 +80,13 @@ pub fn (node &FnDecl) stringify(t &table.Table, cur_mod string) string {
|
||||||
}
|
}
|
||||||
s = util.no_cur_mod(s, cur_mod)
|
s = util.no_cur_mod(s, cur_mod)
|
||||||
if should_add_type {
|
if should_add_type {
|
||||||
if node.is_variadic && is_last_arg {
|
if !is_type_only {
|
||||||
f.write(' ...' + s)
|
f.write(' ')
|
||||||
} else {
|
|
||||||
f.write(' ' + s)
|
|
||||||
}
|
}
|
||||||
|
if node.is_variadic && is_last_arg {
|
||||||
|
f.write('...')
|
||||||
|
}
|
||||||
|
f.write(s)
|
||||||
}
|
}
|
||||||
if !is_last_arg {
|
if !is_last_arg {
|
||||||
f.write(', ')
|
f.write(', ')
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
fn C.PQgetvalue(voidptr, int, int) byteptr
|
|
@ -208,7 +208,6 @@ fn (mut g Gen) write_defer_stmts_when_needed() {
|
||||||
fn (mut g Gen) fn_args(args []table.Param, is_variadic bool) ([]string, []string) {
|
fn (mut g Gen) fn_args(args []table.Param, is_variadic bool) ([]string, []string) {
|
||||||
mut fargs := []string{}
|
mut fargs := []string{}
|
||||||
mut fargtypes := []string{}
|
mut fargtypes := []string{}
|
||||||
no_names := args.len > 0 && args[0].name == 'arg_1'
|
|
||||||
for i, arg in args {
|
for i, arg in args {
|
||||||
caname := c_name(arg.name)
|
caname := c_name(arg.name)
|
||||||
typ := g.unwrap_generic(arg.typ)
|
typ := g.unwrap_generic(arg.typ)
|
||||||
|
@ -245,11 +244,6 @@ fn (mut g Gen) fn_args(args []table.Param, is_variadic bool) ([]string, []string
|
||||||
g.write(')')
|
g.write(')')
|
||||||
g.definitions.write(')')
|
g.definitions.write(')')
|
||||||
}
|
}
|
||||||
} else if no_names {
|
|
||||||
g.write(arg_type_name)
|
|
||||||
g.definitions.write(arg_type_name)
|
|
||||||
fargs << ''
|
|
||||||
fargtypes << arg_type_name
|
|
||||||
} else {
|
} else {
|
||||||
mut nr_muls := arg.typ.nr_muls()
|
mut nr_muls := arg.typ.nr_muls()
|
||||||
s := arg_type_name + ' ' + caname
|
s := arg_type_name + ' ' + caname
|
||||||
|
|
|
@ -900,7 +900,6 @@ fn (mut g JsGen) gen_method_decl(it ast.FnDecl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut g JsGen) fn_args(args []table.Param, is_variadic bool) {
|
fn (mut g JsGen) fn_args(args []table.Param, is_variadic bool) {
|
||||||
// no_names := args.len > 0 && args[0].name == 'arg_1'
|
|
||||||
for i, arg in args {
|
for i, arg in args {
|
||||||
name := g.js_name(arg.name)
|
name := g.js_name(arg.name)
|
||||||
is_varg := i == args.len - 1 && is_variadic
|
is_varg := i == args.len - 1 && is_variadic
|
||||||
|
|
|
@ -253,6 +253,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||||
// Args
|
// Args
|
||||||
args2, are_args_type_only, is_variadic := p.fn_args()
|
args2, are_args_type_only, is_variadic := p.fn_args()
|
||||||
params << args2
|
params << args2
|
||||||
|
if !are_args_type_only {
|
||||||
for param in params {
|
for param in params {
|
||||||
if p.scope.known_var(param.name) {
|
if p.scope.known_var(param.name) {
|
||||||
p.error_with_pos('redefinition of parameter `$param.name`', param.pos)
|
p.error_with_pos('redefinition of parameter `$param.name`', param.pos)
|
||||||
|
@ -266,6 +267,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||||
is_arg: true
|
is_arg: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mut end_pos := p.prev_tok.position()
|
mut end_pos := p.prev_tok.position()
|
||||||
// Return type
|
// Return type
|
||||||
mut return_type := table.void_type
|
mut return_type := table.void_type
|
||||||
|
@ -430,7 +432,6 @@ fn (mut p Parser) fn_args() ([]table.Param, bool, bool) {
|
||||||
// p.warn('types only')
|
// p.warn('types only')
|
||||||
mut arg_no := 1
|
mut arg_no := 1
|
||||||
for p.tok.kind != .rpar {
|
for p.tok.kind != .rpar {
|
||||||
arg_name := 'arg_$arg_no'
|
|
||||||
is_shared := p.tok.kind == .key_shared
|
is_shared := p.tok.kind == .key_shared
|
||||||
is_atomic := p.tok.kind == .key_atomic
|
is_atomic := p.tok.kind == .key_atomic
|
||||||
is_mut := p.tok.kind == .key_mut || is_shared || is_atomic
|
is_mut := p.tok.kind == .key_mut || is_shared || is_atomic
|
||||||
|
@ -480,7 +481,7 @@ fn (mut p Parser) fn_args() ([]table.Param, bool, bool) {
|
||||||
sym := p.table.get_type_symbol(arg_type)
|
sym := p.table.get_type_symbol(arg_type)
|
||||||
args << table.Param{
|
args << table.Param{
|
||||||
pos: pos
|
pos: pos
|
||||||
name: arg_name
|
name: ''
|
||||||
is_mut: is_mut
|
is_mut: is_mut
|
||||||
typ: arg_type
|
typ: arg_type
|
||||||
type_source_name: sym.source_name
|
type_source_name: sym.source_name
|
||||||
|
|
Loading…
Reference in New Issue