alex

/

v Public
0 Issues 1 Contributor 0 Releases 4 Branches
Additions: 15 Deletions: 4 View patch
1 && c.table.cur_concrete_types.len == 0 {
2 pos := type_sym.name.last_index('.') or { -1 }
3 first_letter := type_sym.name[pos + 1]
4- if !first_letter.is_capital() && type_sym.kind != .placeholder {
5- c.error('cannot initialize builtin type `$type_sym.name`', node.pos)
6+ if !first_letter.is_capital() && type_sym.kind != .placeholder
7+ && !type_sym.name.starts_with('_VAnonStruct') {
8+ s := type_sym.name
9+ x := s.starts_with('_')
10+
11+ c.error('cannot initialize builtin type1 $x "$s" "${s[..4]}" `$type_sym.name`',
12+ node.pos)
13 }
14 }
15 if type_sym.kind == .sum_type && node.fields.len == 1 {
16
1 node = p.map_init()
2 p.check(.rcbr)
3 }
4+ .key_struct {
5+ // Anonymous struct
6+ p.next()
7+ return p.struct_init('', false)
8+ }
9 .key_fn {
10 if p.expecting_type {
11 // Anonymous function type
12
1 }
2
3 fn test_anon() {
4- empty_book := Book{} // author:struct{'sdf', 23}}
5+ empty_book := Book{}
6 assert empty_book.author.age == 0
7 assert empty_book.author.name == ''
8-
9 println(empty_book.author.age)
10+
11+ book := Book{ author:struct{'sdf', 23}}
12 }
13