%type <list> interfacedcl_list vardcl vardcl_list structdcl structdcl_list
%type <list> common_dcl constdcl constdcl1 constdcl_list typedcl_list
-%type <node> convtype dotdotdot littype
+%type <node> convtype dotdotdot
%type <node> indcl interfacetype structtype ptrtype
%type <node> chantype non_chan_type othertype non_fn_type fntype
if($2 == LBODY)
loophack = 1;
}
-| littype '{' braced_keyval_list '}'
+| pexpr '{' braced_keyval_list '}'
{
// composite expression
$$ = nod(OCOMPLIT, N, $1);
}
| fnliteral
-littype:
- name
-| pexpr '.' sym
- {
- if($1->op == OPACK) {
- Sym *s;
- s = restrictlookup($3->name, $1->sym->name);
- $1->used = 1;
- $$ = oldname(s);
- break;
- }
- $$ = nod(OXDOT, $1, newname($3));
- }
-
expr_or_type:
expr
| non_expr_type %prec PreferToRightParen
}
| structtype
-
/*
* to avoid parsing conflicts, type is split into
* channel types
{
$$ = nod(OTARRAY, $2, $4);
}
+| '[' dotdotdot ']' ntype
+ {
+ // array literal of nelem
+ $$ = nod(OTARRAY, $2, $4);
+ }
| LCOMM LCHAN ntype
{
$$ = nod(OTCHAN, $3, N);
pair { (bool)(false), "true" },
pair { (*int8)(nil), "*int8(0)" },
pair { (**int8)(nil), "**int8(0)" },
- pair { [5]int32{}, "[5]int32{0, 0, 0, 0, 0}" },
+ pair { ([5]int32){}, "[5]int32{0, 0, 0, 0, 0}" },
pair { (**integer)(nil), "**reflect_test.integer(0)" },
pair { (map[string]int32)(nil), "map[string] int32{<can't iterate on maps>}" },
pair { (chan<-string)(nil), "chan<- string" },
- pair { struct {c chan *int32; d float32}{}, "struct { c chan *int32; d float32 }{chan *int32, 0}" },
+ pair { (struct {c chan *int32; d float32}){}, "struct { c chan *int32; d float32 }{chan *int32, 0}" },
pair { (func(a int8, b int32))(nil), "func(int8, int32)(0)" },
- pair { struct {c func(chan *integer, *int8)}{}, "struct { c func(chan *reflect_test.integer, *int8) }{func(chan *reflect_test.integer, *int8)(0)}" },
- pair { struct {a int8; b int32}{}, "struct { a int8; b int32 }{0, 0}" },
- pair { struct {a int8; b int8; c int32}{}, "struct { a int8; b int8; c int32 }{0, 0, 0}" },
+ pair { (struct {c func(chan *integer, *int8)}){}, "struct { c func(chan *reflect_test.integer, *int8) }{func(chan *reflect_test.integer, *int8)(0)}" },
+ pair { (struct {a int8; b int32}){}, "struct { a int8; b int32 }{0, 0}" },
+ pair { (struct {a int8; b int8; c int32}){}, "struct { a int8; b int8; c int32 }{0, 0, 0}" },
}
func testType(t *testing.T, i int, typ Type, want string) {