Skip to content

Commit

Permalink
style: printArg doesn't return error
Browse files Browse the repository at this point in the history
  • Loading branch information
gbotrel committed Sep 20, 2021
1 parent 59110ae commit f624d36
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions frontend/cs_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,22 @@ func (cs *ConstraintSystem) Println(a ...interface{}) {
cs.logs = append(cs.logs, log)
}

func printArg(log *compiled.LogEntry, sbb *strings.Builder, a interface{}) error {
func printArg(log *compiled.LogEntry, sbb *strings.Builder, a interface{}) {

count := 0
counter := func(visibility compiled.Visibility, name string, tValue reflect.Value) error {
count++
return nil
}
if err := parser.Visit(a, "", compiled.Unset, counter, reflect.TypeOf(Variable{})); err != nil {
return err
}
// ignoring error, counter() always return nil
_ = parser.Visit(a, "", compiled.Unset, counter, reflect.TypeOf(Variable{}))

// no variables in nested struct, we use fmt std print function
if count == 0 {
sbb.WriteString(fmt.Sprint(a))
return nil
return
}

sbb.WriteByte('{')
printer := func(visibility compiled.Visibility, name string, tValue reflect.Value) error {
count--
Expand All @@ -88,12 +89,9 @@ func printArg(log *compiled.LogEntry, sbb *strings.Builder, a interface{}) error
log.ToResolve = append(log.ToResolve, compiled.TermDelimitor)
return nil
}
if err := parser.Visit(a, "", compiled.Unset, printer, reflect.TypeOf(Variable{})); err != nil {
return err
}
// ignoring error, printer() doesn't return errors
_ = parser.Visit(a, "", compiled.Unset, printer, reflect.TypeOf(Variable{}))
sbb.WriteByte('}')

return nil
}

func (cs *ConstraintSystem) addDebugInfo(errName string, i ...interface{}) int {
Expand Down

0 comments on commit f624d36

Please sign in to comment.