hcl: When rendering diagnostics, elide complex index keys
In practice this should never arise because the index operator only works for lists and maps and they use string keys, but we'll guard against this anyway and return a placeholder for other values so that the output doesn't grow unreadably long in that case.
This commit is contained in:
parent
f45c1cdace
commit
5919f80710
@ -225,7 +225,13 @@ func (w *diagnosticTextWriter) traversalStr(traversal Traversal) string {
|
||||
buf.WriteString(tStep.Name)
|
||||
case TraverseIndex:
|
||||
buf.WriteByte('[')
|
||||
buf.WriteString(w.valueStr(tStep.Key))
|
||||
if keyTy := tStep.Key.Type(); keyTy.IsPrimitiveType() {
|
||||
buf.WriteString(w.valueStr(tStep.Key))
|
||||
} else {
|
||||
// We'll just use a placeholder for more complex values,
|
||||
// since otherwise our result could grow ridiculously long.
|
||||
buf.WriteString("...")
|
||||
}
|
||||
buf.WriteByte(']')
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user