Another small bug that I found while adding compiler service tests to my scoped nowarn branch.
The regression test in PR #18380 fails without the fix.
(Note that duplicates are reported only by the old BackgroundCompiler, not by TransparentCompiler.)