File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -254,12 +254,19 @@ func quotedStringTokens(value string) hclwrite.Tokens {
254254}
255255
256256// resolvedSourceFile extracts the originating HCL filename from a resolved
257- // autoinclude, used to enrich panic messages with file context. Returns ""
258- // when resolved or its body is nil.
257+ // autoinclude, used to enrich panic messages with file context. Reads the
258+ // SrcRange struct field on the known concrete body type so no interface
259+ // method is invoked — this keeps the helper panic-safe even when called
260+ // from inside a panic formatter.
259261func resolvedSourceFile (resolved * AutoIncludeResolved ) string {
260- if resolved == nil || resolved .RawBody == nil {
262+ if resolved == nil {
263+ return ""
264+ }
265+
266+ body , ok := resolved .RawBody .(* hclsyntax.Body )
267+ if ! ok || body == nil {
261268 return ""
262269 }
263270
264- return resolved . RawBody . MissingItemRange () .Filename
271+ return body . SrcRange .Filename
265272}
You can’t perform that action at this time.
0 commit comments