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 Bool pattern matching to be exhaustive #461

Merged
merged 1 commit into from
Mar 12, 2023

Conversation

lolgab
Copy link
Member

@lolgab lolgab commented Mar 11, 2023

Fixes #456

@lolgab lolgab marked this pull request as ready for review March 11, 2023 11:17
@lolgab lolgab requested review from lihaoyi and lefou March 11, 2023 11:17
Comment on lines +27 to +29
upack.Bool(true) match {
case upack.Bool(value) =>
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test assumes we're using -Xfatal-warnings, right? If not, I don't see how this test is supposed to detect non-exhaustiveness.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. I added it in the previous PR exactly for this test. I don't know if there is a better way to test this.

Copy link
Member

@lefou lefou Mar 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means, if the settings get changed later, we have no indicator that this test becomes insufficient. The bare minimum is a comment in code or in the test name. A bit better would be to detect the flags (e.g. by generating some build info code). I know utest has compileError; maybe it also fails a warning under -Xfatal-warnings, in which case we could guard some code that emits a warning with compileError to detect when this setting gets removed in the future?

@lihaoyi
Copy link
Member

lihaoyi commented Mar 12, 2023

Gonna merge this to get it in for the 3.0.0 release

@lihaoyi lihaoyi merged commit 7e469da into com-lihaoyi:main Mar 12, 2023
@lolgab lolgab deleted the fix-Bool-pattern-matching branch March 12, 2023 01:38
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.

ujson.Bool.unapply generates match may not be exhaustive warning
3 participants