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 compiler warning about non-exhaustive match #83

Merged
merged 2 commits into from
Oct 18, 2016

Conversation

ashawley
Copy link
Member

Specific warning looks like this:

src/test/scala/scala/xml/ReuseNodesTest.scala:86: match may not be exhaustive.
It would fail on the following inputs: (List(_), Nil), (Nil, List(_))
    (original.toList,transformed.toList) match {
    ^
one warning found

Seems like the method could be rewritten to just use zip and foreach. Could someone review to make sure the assertion still works, though? I wasn't sure how to break scala.xml.transform.BasicTransformer to verify.

@biswanaths
Copy link
Contributor

Face Palm. Big thanks for correcting my spell mistakes.

@ashawley
Copy link
Member Author

ashawley commented Oct 5, 2015

@biswanaths Would it be possible to write a unit test that verifies that I didn't introduce a bug, and that I preserved the fix in in #59? Seems like a unit test that uses a counter to count the number of times a function was called, as was shown in https://issues.scala-lang.org/browse/SI-4528 could do that?

@biswanaths
Copy link
Contributor

Sure @ashawley, let me look into writing the mentioned unit test. The counter validation will definitely strengthen validation any fix, pointing linear time complexity.

@biswanaths
Copy link
Contributor

Is there a way to write a count test for the code, without modifying the existing code ? I was thinking of inheriting and overriding the transform ( https://github.com/scala/scala-xml/blob/master/src/main/scala/scala/xml/transform/BasicTransformer.scala#L34) + plus incrementing the state in the derived. Any other ways, people can think of ?

@ashawley
Copy link
Member Author

@biswanaths Yes, using a var counter seems appropriate to me.

@biswanaths
Copy link
Contributor

Ok, will submit a pull request with that.

@ashawley
Copy link
Member Author

ashawley commented Nov 4, 2015

@biswanaths I've added one for you. When you've verified the new unit test and merged it, I will rebase and push this PR so the Travis checks can run again.

@ashawley ashawley force-pushed the unexhaustive-match-warning branch from 01157da to 36a9b22 Compare February 29, 2016 05:52
@ashawley
Copy link
Member Author

@biswanaths Thanks! After you merged, I've rebased and re-pushed this branch. Looks like the checks still passed.

@ashawley ashawley force-pushed the unexhaustive-match-warning branch from 36a9b22 to 7aaa833 Compare April 22, 2016 20:02
@ashawley ashawley force-pushed the unexhaustive-match-warning branch from 7aaa833 to b3802e1 Compare June 12, 2016 22:25
@ashawley ashawley force-pushed the unexhaustive-match-warning branch 2 times, most recently from f42d1b3 to fca8638 Compare September 20, 2016 22:09
src/test/scala/scala/xml/ReuseNodesTest.scala:86: match may not be exhaustive.
It would fail on the following inputs: (List(_), Nil), (Nil, List(_))
    (original.toList,transformed.toList) match {
    ^
one warning found
@ashawley ashawley force-pushed the unexhaustive-match-warning branch from fca8638 to 713d2d9 Compare October 17, 2016 13:14
@biswanaths
Copy link
Contributor

@ashawley , this looks good to me. Should we merge this in ?

@ashawley
Copy link
Member Author

@biswanaths Yes, it is ready to go. It has the latest commits from master.

I think it is worth merging. It would be nice to get rid of the warnings from the build output in SBT.

@biswanaths biswanaths merged commit 713d2d9 into scala:master Oct 18, 2016
@biswanaths
Copy link
Contributor

Thanks @ashawley . Sorry that I missed it for long time.

@ashawley ashawley deleted the unexhaustive-match-warning branch October 18, 2016 14:36
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.

2 participants