Skip to content
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

Fix for #1430 #1591

Merged
merged 3 commits into from Sep 13, 2014
Merged

Fix for #1430 #1591

merged 3 commits into from Sep 13, 2014

Conversation

cunei
Copy link

@cunei cunei commented Sep 11, 2014

In Relation, _1s is defined as "Returns the set of all _1s such that (_1, _2) is in this relation.". Which is false: it is implemented as fwd.keySet, but it should be fwd.filterNot(_._2.isEmpty).keySet. Except setAll() depends on the incorrect semantics, and the apparently innocuous optimization in 322f6de broke it as a result. This pull request reverts the change, pending an implementation of setAll which does not depend on _1s (after which _1s can probably be fixed). See #1430.

Antonio Cunei added 2 commits September 11, 2014 02:03
To test, use:
> scripted tests/set-every
The implementation of Relation should in theory make no difference
whether an element is unmapped, or whether it is mapped to an empty
set. One of the changes in 322f6de
introduced an optimization to the '+' operation on Relations that,
in theory, should have made no difference to the semantic.

The result of that optimization is that some mappings of the form
"elem -> Set()" are no longer inserted in the forwardMap of the
Relation.

Unfortunately, the change resulted in the breakage of sbt#1430,
causing "set every" to behave incorrectly. There must be, somewhere
in the code, a test on the presence of a key rather than an access
via <relation>.get(), or some other access that bypasses the
supposed semantic equivalence described above. I spent several
hours trying to track down exactly the offending test, without
success.

By undoing the relevant change in 322f6de, "set every"
works again. That however offers no guarantee that everything else
will keep working correctly; the underlying quirk in the code that
depends on this supposedly inessential detail is also still
lurking in the code, which is less than ideal.
@jsuereth
Copy link
Member

Hmm, look like this breaks the logic unit tests, so it appears we have something relying on the NEW behavior too. I'll investigate.

The optimization, and therefore the change in the behavior
of Relation, is now needed by the class Logic, and cannot
be reverted.

This patch (written by Josh) therefore changes the
implementation of setAll() so that _1s is no longer used.
@jsuereth
Copy link
Member

LGTM, after travis is green we can merge!

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.

None yet

3 participants