Skip to content

Skip -/+ swaps for unary ops in match-case patterns - #589

Open
GhostCoder6969 wants to merge 1 commit into
boxed:mainfrom
GhostCoder6969:fix-match-case-unary
Open

GhostCoder6969 wants to merge 1 commit into
boxed:mainfrom
GhostCoder6969:fix-match-case-unary

Conversation

@GhostCoder6969

Copy link
Copy Markdown

Fixes #583.

Mutating case -2 produced case +2, which is a syntax error, so the mutant could never run. Unary plus just is not valid in patterns. The fix tracks unary operations inside match case patterns and skips the operator swap for those nodes only. Everything else still mutates like before, x = -2 still gets its +2 mutant since that one is fine.

I added a regression test that checks no +2 mutant comes out of a match case and that every generated mutant compiles. The test fails on unpatched code and passes with the fix, and the mutation suite shows no new failurs.

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.

Invalid unary plus generated in match statement

1 participant