vfmt: fix struct init; run on struct_test.v

pull/4322/head
Alexander Medvednikov 2020-04-10 00:36:50 +02:00
parent 9b2511133d
commit d5fb68e3d6
3 changed files with 18 additions and 13 deletions

View File

@ -653,7 +653,7 @@ fn (f mut Fmt) expr(node ast.Expr) {
f.write('$name{}')
} else if it.fields.len == 0 {
// `Foo{1,2,3}` (short syntax )
f.write('{')
f.write('$name{')
for i, expr in it.exprs {
f.expr(expr)
if i < it.exprs.len - 1 {

View File

@ -32,8 +32,8 @@ fn (p mut Parser) hash() ast.HashStmt {
p.cur_tok_index() - 1)
}
flag = flag.replace('@VROOT', vmod_file_location.vmod_folder )
*/
flag = flag.replace('@VROOT', '/Users/alex/code/v/')
*/
}
for deprecated in ['@VMOD', '@VMODULE', '@VPATH', '@VLIB_PATH'] {
if flag.contains(deprecated) {

View File

@ -65,10 +65,7 @@ fn test_empty_struct() {
println(d) // != voidptr(0)
println('empty:')
println(d2) // empty struct print
println(sizeof(
Empty
)
) // == 0
println(sizeof(Empty)) // == 0
}
fn test_struct_levels() {
@ -109,9 +106,9 @@ u := User{'Bob',30}
fn test_at() {
foo := Foo{
typ: 'test' // QTODO @type
//type: 'test'
typ: 'test'
}
// type: 'test'
println(foo.typ)
}
@ -255,8 +252,16 @@ struct City {
}
struct Country {
name string
capital City
}
fn test_levels() {
c := Country{
name: 'UK'
capital: {
name: 'London'
population: 10
}
}
}