Skip to content

Commit

Permalink
Fixed string alias annotation problem
Browse files Browse the repository at this point in the history
Issue #50. Happened when a string alias type (with no actual type
restrictions occurred) was annotated.
  • Loading branch information
Lee Boynton committed Jul 19, 2017
1 parent cbf2cfd commit bf76181
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rdl/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ func (p *parser) parseStringTypeDef(t *StringTypeDef, base string) *StringTypeDe
}
}
t.Comment = p.statementEnd(t.Comment)
if t.MaxSize == nil && t.MinSize == nil && t.Pattern == "" && t.Values == nil {
if t.MaxSize == nil && t.MinSize == nil && t.Pattern == "" && t.Values == nil && t.Annotations == nil {
return nil
}
return t
Expand Down
12 changes: 12 additions & 0 deletions rdl/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,15 @@ type Foo Struct {
return
}
}

func TestAliasAnnotation(test *testing.T) {
_, err := parseRDLString(`
type DateTime string (x_date_time)
type Response struct {
DateTime dateTime (optional);
}`)
if err != nil {
test.Errorf("cannot parse valid RDL: %v", err)
return
}
}

0 comments on commit bf76181

Please sign in to comment.