Skip to content

Commit

Permalink
Update Struct.String() function to not quote starlark.String custom c…
Browse files Browse the repository at this point in the history
…onstructor (#449)
  • Loading branch information
Guillaume Bouvignies authored Jan 12, 2023
1 parent dcdc0f0 commit fae38c8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions starlarkstruct/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ func (s *Struct) ToStringDict(d starlark.StringDict) {

func (s *Struct) String() string {
buf := new(strings.Builder)
if s.constructor == Default {
switch constructor := s.constructor.(type) {
case starlark.String:
// NB: The Java implementation always prints struct
// even for Bazel provider instances.
buf.WriteString("struct") // avoid String()'s quotation
} else {
buf.WriteString(constructor.GoString()) // avoid String()'s quotation
default:
buf.WriteString(s.constructor.String())
}
buf.WriteByte('(')
Expand Down

0 comments on commit fae38c8

Please sign in to comment.