vfmt: fix struct init; run on struct_test.v
parent
9b2511133d
commit
d5fb68e3d6
|
@ -653,7 +653,7 @@ fn (f mut Fmt) expr(node ast.Expr) {
|
||||||
f.write('$name{}')
|
f.write('$name{}')
|
||||||
} else if it.fields.len == 0 {
|
} else if it.fields.len == 0 {
|
||||||
// `Foo{1,2,3}` (short syntax )
|
// `Foo{1,2,3}` (short syntax )
|
||||||
f.write('{')
|
f.write('$name{')
|
||||||
for i, expr in it.exprs {
|
for i, expr in it.exprs {
|
||||||
f.expr(expr)
|
f.expr(expr)
|
||||||
if i < it.exprs.len - 1 {
|
if i < it.exprs.len - 1 {
|
||||||
|
|
|
@ -32,8 +32,8 @@ fn (p mut Parser) hash() ast.HashStmt {
|
||||||
p.cur_tok_index() - 1)
|
p.cur_tok_index() - 1)
|
||||||
}
|
}
|
||||||
flag = flag.replace('@VROOT', vmod_file_location.vmod_folder )
|
flag = flag.replace('@VROOT', vmod_file_location.vmod_folder )
|
||||||
*/
|
|
||||||
flag = flag.replace('@VROOT', '/Users/alex/code/v/')
|
flag = flag.replace('@VROOT', '/Users/alex/code/v/')
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
for deprecated in ['@VMOD', '@VMODULE', '@VPATH', '@VLIB_PATH'] {
|
for deprecated in ['@VMOD', '@VMODULE', '@VPATH', '@VLIB_PATH'] {
|
||||||
if flag.contains(deprecated) {
|
if flag.contains(deprecated) {
|
||||||
|
|
|
@ -65,10 +65,7 @@ fn test_empty_struct() {
|
||||||
println(d) // != voidptr(0)
|
println(d) // != voidptr(0)
|
||||||
println('empty:')
|
println('empty:')
|
||||||
println(d2) // empty struct print
|
println(d2) // empty struct print
|
||||||
println(sizeof(
|
println(sizeof(Empty)) // == 0
|
||||||
Empty
|
|
||||||
)
|
|
||||||
) // == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_struct_levels() {
|
fn test_struct_levels() {
|
||||||
|
@ -109,9 +106,9 @@ u := User{'Bob',30}
|
||||||
|
|
||||||
fn test_at() {
|
fn test_at() {
|
||||||
foo := Foo{
|
foo := Foo{
|
||||||
typ: 'test' // QTODO @type
|
typ: 'test'
|
||||||
//type: 'test'
|
|
||||||
}
|
}
|
||||||
|
// type: 'test'
|
||||||
println(foo.typ)
|
println(foo.typ)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,8 +252,16 @@ struct City {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Country {
|
struct Country {
|
||||||
|
name string
|
||||||
capital City
|
capital City
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_levels() {
|
fn test_levels() {
|
||||||
|
c := Country{
|
||||||
|
name: 'UK'
|
||||||
|
capital: {
|
||||||
|
name: 'London'
|
||||||
|
population: 10
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue