Skip to content

Commit

Permalink
Only check for Mapping in the uncommon case
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSignPainter98 committed Nov 21, 2023
1 parent 29995da commit 0c90a3d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions starlark/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1659,11 +1659,14 @@ func interpolate(format string, x Value) (Value, error) {
index++
}

if _, ok := x.(Mapping); !ok {
if index < nargs {
return nil, fmt.Errorf("too many arguments for format string")
}
if index < nargs && !is[Mapping](x) {
return nil, fmt.Errorf("too many arguments for format string")
}

return String(buf.String()), nil
}

func is[T any](x any) bool {
_, ok := x.(T)
return ok
}

0 comments on commit 0c90a3d

Please sign in to comment.