cmd/hclspecsuite: Generate correct ranges in diagnostic-diagnostics

We were taking a pointer to a for loop iterator variable and thus
capturing the final iteration value rather than each one separately. By
using the .Ptr() method instead, we force a copy of the range which we
then take a pointer to.
This commit is contained in:
Martin Atkins 2018-12-14 11:33:28 -08:00
parent e8dbb16dbc
commit 2934d2f033
1 changed files with 2 additions and 2 deletions

View File

@ -283,7 +283,7 @@ func (r *Runner) runTestInput(specFilename, inputFilename string, tf *TestFile)
"No %s diagnostic was expected %s. The unexpected diagnostic was shown above.",
severityString(gotEntry.Severity), rangeString(gotEntry.Range),
),
Subject: &gotEntry.Range,
Subject: gotEntry.Range.Ptr(),
})
}
}
@ -297,7 +297,7 @@ func (r *Runner) runTestInput(specFilename, inputFilename string, tf *TestFile)
"No %s diagnostic was generated %s.",
severityString(wantEntry.Severity), rangeString(wantEntry.Range),
),
Subject: &declRange,
Subject: declRange.Ptr(),
})
}
}