Add position-independent diagnostic syntax to syntax tests#11188
Add position-independent diagnostic syntax to syntax tests#11188tilladam wants to merge 2 commits intoslint-ui:masterfrom
Conversation
Add `//-error{message}` and `//-warning{message}` syntax for matching
diagnostics by message and level only, ignoring source position. This
is useful for binding loop warnings on layout properties where the
diagnostic position varies across platforms due to analysis traversal
order differences.
|
I'm curious what makes the position change across platform. What i have noticed is that sometimes diagnostics are not attached to a location and a file and this feature could help, although i don't know if it would work as is because there is also not a file. |
|
The non-determinism comes from While Additionally, at line 346, For the case of diagnostics without a file — the current implementation requires matching against a specific file's source, so position-independent matching within a file wouldn't help with that case. That would need a separate mechanism. |
|
@tilladam Then IMO the better solution is to not use HashSet and use a BTreeSet instead, which is deterministic. |
|
You are right, droppign this one in favor of #11219 |
|
After investigating @ogoffart's point further, I agree that the I did find a real source of non-determinism: However, I can't confirm locally that this is the specific cause of the cross-platform diagnostic position differences in #10552 — that would need CI validation. So the position-independent diagnostic syntax proposed here may still be needed if other sources of non-determinism remain. |
Summary
//-error{message}and//-warning{message}syntax for matching diagnostics by message and level only, ignoring source positionThis is needed by #10552 (binding loop detection for callbacks), where several syntax tests fail on CI because layout binding loop warnings are emitted at platform-dependent source locations.
Test plan
self_testpasses — 3 new assertions (positive, wrong message, wrong level)syntax_testspasses — no regressions in existing tests