diff --git a/param_test.go b/param_test.go index 48f5e42..7ee81d3 100644 --- a/param_test.go +++ b/param_test.go @@ -472,6 +472,10 @@ func TestStructErrors(t *testing.T) { t.Error("expected error parsing struct without key") } + if _, ok := err.(SyntaxError); !ok { + t.Error("expected SyntaxError parsing struct without key") + } + err = Parse(url.Values{"Struct[": {"llama"}}, &e) if err == nil { t.Error("expected error parsing malformed struct key") diff --git a/parse.go b/parse.go index b8c069d..6386da7 100644 --- a/parse.go +++ b/parse.go @@ -77,7 +77,7 @@ func primitive(key, keytail string, tipe reflect.Type, values []string) { } func keyed(tipe reflect.Type, key, keytail string) (string, string) { - if keytail[0] != '[' { + if keytail == "" || keytail[0] != '[' { panic(SyntaxError{ Key: kpath(key, keytail), Subtype: MissingOpeningBracket,