Skip to content

RequirementMachine: Fix bad interaction between rule sharing and conditional requirement inference #41838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Mar 16, 2022

I noticed this by inspection after merging 26132bc3e96e4c190da4efc624dcd505b435e58b; I forgot to add imported rules from protocols appearing on the right hand sides of conditional requirements.

None of our existing test cases caught this, so I added a new test.

I refactored the RuleBuilder so that the weird thing that conditional requirement inference does where it adds new requirements to a rewrite system during completion is now much cleaner.

Also this PR adds an unrelated performance/diagnostics test case from an old radar.

…onditionalRequirements()

This fixes a regression from the rule sharing implementation; I forgot
to handle the imported rules in builder.ImportedRules here.

This makes the usage of RuleBuilder in conditional requirement
inference look like the other usages of RuleBuilder, except
that the results are passed to RewriteSystem::addRules() instead
of RewriteSystem::initialize().
Completion has a maximum rule limit since the Knuth-Bendix algorithm
is a semi-decision procedure that does not terminate on all inputs.

However, this means that generic signatures which import a large
number of complex protocols can hit the limit even if they are
convergent.

Since imported rules are essentially free, ignore them here, to
avoid having to increase the limit by hand.

Now the default limit is 4000 local rules per requirement machine;
it seems implausible that you would exceed this, but if anyone has
an example we can bump the limit again.
@slavapestov slavapestov force-pushed the rqm-conditional-requirement-inference-vs-rule-sharing branch from 26132bc to 6e6c8c2 Compare March 16, 2022 17:26
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit 6c0ccfc into swiftlang:main Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant