Skip to content

Regex is always mutated into uncompilable code #3241

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

Open
eNeRGy164 opened this issue May 16, 2025 · 0 comments
Open

Regex is always mutated into uncompilable code #3241

eNeRGy164 opened this issue May 16, 2025 · 0 comments
Labels
🐛 Bug Something isn't working

Comments

@eNeRGy164
Copy link
Contributor

Describe the bug
I have a simple regex in my code, all mutations are invalid as the constructor is removed in the result.

public bool TestInput(string input)
{
    var regex = new Regex(@"^[0-9]{3,}$");

    return regex.IsMatch(input);
}

Mutations

There are multiple, all causing the same compilation error, but 3 examples:

Regex anchor removal mutation:

-   var regex = new Regex(@"^[0-9]{3,}$");
+   var regex = "^[0-9]{3,}"

Regex greedy quantifier quantity mutation:

-   var regex = new Regex(@"^[0-9]{3,}$");
+   var regex = "^[0-9]{4,}"

Regex character class range modification:

-   var regex = new Regex(@"^[0-9]{3,}$");
+   var regex = "^[0-8]{3,}$"

Tested both with var and explicit type.

Expected behavior
No compilation errors.

Desktop (please complete the following information):

  • OS: Windows
  • Type of project: .NET
  • Framework Version: 9.0
  • Stryker Version: 4.5.1
@eNeRGy164 eNeRGy164 added the 🐛 Bug Something isn't working label May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant