array: rename default to init

pull/4888/head
Alexander Medvednikov 2020-05-13 22:00:24 +02:00
parent ab7bc760c6
commit 1bf26a35fa
3 changed files with 5 additions and 5 deletions

View File

@ -979,7 +979,7 @@ fn (mut f Fmt) array_init(it ast.ArrayInit) {
f.expr(it.cap_expr) f.expr(it.cap_expr)
} }
if it.has_default { if it.has_default {
f.write('default: ') f.write('init: ')
f.expr(it.default_expr) f.expr(it.default_expr)
} }
f.write('}') f.write('}')
@ -1003,7 +1003,7 @@ fn (mut f Fmt) array_init(it ast.ArrayInit) {
} }
} }
if it.has_default { if it.has_default {
f.write('default: ') f.write('init: ')
f.expr(it.default_expr) f.expr(it.default_expr)
} }
f.write('}') f.write('}')

View File

@ -9,6 +9,6 @@ fn main() {
make_flag('darwin', '-framework', 'Cocoa'), make_flag('darwin', '-framework', 'Cocoa'),
make_flag('windows', '-l', 'gdi32') make_flag('windows', '-l', 'gdi32')
] ]
x := []int{len: 10, cap: 100, default: 1} x := []int{len: 10, cap: 100, init: 1}
_ := expected_flags _ := expected_flags
} }

View File

@ -91,12 +91,12 @@ fn (mut p Parser) array_init() ast.ArrayInit {
has_cap = true has_cap = true
cap_expr = p.expr(0) cap_expr = p.expr(0)
} }
'default' { 'init' {
has_default = true has_default = true
default_expr = p.expr(0) default_expr = p.expr(0)
} }
else { else {
p.error('wrong field `$key`, expecting `len`, `cap`, or `default`') p.error('wrong field `$key`, expecting `len`, `cap`, or `init`')
} }
} }
if p.tok.kind != .rcbr { if p.tok.kind != .rcbr {