mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
This commit is contained in:
parent
171df75cc7
commit
18f1874586
4 changed files with 30 additions and 1 deletions
|
@ -340,10 +340,15 @@ fn (mut g Gen) const_decl_init_later(mod string, name string, expr ast.Expr, typ
|
||||||
func := (expr_sym.info as ast.FnType).func
|
func := (expr_sym.info as ast.FnType).func
|
||||||
def = g.fn_var_signature(func.return_type, func.params.map(it.typ), cname)
|
def = g.fn_var_signature(func.return_type, func.params.map(it.typ), cname)
|
||||||
}
|
}
|
||||||
|
init_str := init.str().trim_right('\n')
|
||||||
g.global_const_defs[util.no_dots(name)] = GlobalConstDef{
|
g.global_const_defs[util.no_dots(name)] = GlobalConstDef{
|
||||||
mod: mod
|
mod: mod
|
||||||
def: '${def}; // inited later'
|
def: '${def}; // inited later'
|
||||||
init: init.str().trim_right('\n')
|
init: if init_str.count('\n') > 1 {
|
||||||
|
'{\n${init_str}\n}'
|
||||||
|
} else {
|
||||||
|
init_str
|
||||||
|
}
|
||||||
dep_names: g.table.dependent_names_in_expr(expr)
|
dep_names: g.table.dependent_names_in_expr(expr)
|
||||||
}
|
}
|
||||||
if g.is_autofree {
|
if g.is_autofree {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
pub struct JwtHeader {
|
||||||
|
pub:
|
||||||
|
alg string
|
||||||
|
typ string
|
||||||
|
cty string
|
||||||
|
}
|
||||||
|
|
||||||
|
const f1 = json.encode(JwtHeader{ alg: '1', typ: '2', cty: '3' })
|
|
@ -0,0 +1,5 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
const f2 = json.encode(JwtHeader{ alg: 'a', typ: 'b', cty: 'c' })
|
|
@ -0,0 +1,7 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println(f1)
|
||||||
|
println(f2)
|
||||||
|
println('OK')
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue