Fix #87349: Filter cartesian products from pack diagnostics#87366
Fix #87349: Filter cartesian products from pack diagnostics#87366vanshkamra12 wants to merge 1 commit intoswiftlang:mainfrom
Conversation
Issue: diagnoseConflictingGenericArguments showed duplicate and cartesian product pack types (e.g., 8 types instead of 2). Solution: Implemented extremal heuristic filtering: - Count unique types in each pack - Keep only packs with min/max unique counts - Filter out intermediate 'mixed' cartesian products Result: Shows only actual argument packs (2 types instead of 8).
|
@a-viv-a please review it..!!! |
|
For a case like |
|
Hi @a-viv-a , I've implemented the fix for #87349 with the following results: Working perfectly: 2-parameter conflicts: Shows exactly 2 types (no duplicates) Current: Shows 4 types: {String×3}, {Int×3}, {String,Int,String}, {Int,String,String} Question: Is the current solution acceptable (4 types with useful information), or would you like me to investigate constraint solver modifications? |
|
Assuming the tests you added pass: This shows no actual conflicting arguments, so I don't think we can solve this in this way even if the fix works in some cases. I think there's a broader thing that needs to be done in how the constraint solver explores packs? |
|
Hi @a-viv-a , Thank you so much for taking the time to review my PR and provide such clear feedback! I really appreciate your insight. You're absolutely right - I see now that my filtering approach doesn't show the actual position-wise conflicts. For the test case Data2(a: 1,2,3, b: 1,2,true, c: "a","b","c"), the real conflicts should be: Position 0: {Int, Int, String} What my current solution accomplishes:
I completely understand that this needs to be addressed at the constraint solver level - specifically in how pack exploration generates and tracks these conflicts. I'd love to work on this in parallel with my current PR to understand the deeper architecture better. Would you be able to point me to where in the constraint solver the pack exploration happens? I'm excited to dig into this and see if I can contribute to a more complete solution. This has been a great learning experience in understanding the boundary between diagnostic filtering and constraint solving! Thank you again for your guidance and patience! |
|
I'm new to working on the swift compiler, so I'm not sure I can point you in the right direction, sorry 😅 |
Fixes #87349
This PR addresses the issue where pack generic parameter diagnostics were showing
duplicate types and cartesian products generated by the constraint solver.
Problem
When diagnosing conflicting generic arguments with pack types, the diagnostic would
show 8 types instead of 2, including duplicates and solver-generated cartesian products.
Solution
Implemented a two-level filtering approach:
filtering out intermediate "mixed" cartesian products
Result
Diagnostics now show only the actual argument packs (2 types instead of 8).
Testing
Added comprehensive test cases covering various pack type scenarios.