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

Data flow doesn't track per-branch values correctly #2550

Open
vitek-karas opened this issue Jan 26, 2022 · 0 comments
Open

Data flow doesn't track per-branch values correctly #2550

vitek-karas opened this issue Jan 26, 2022 · 0 comments

Comments

@vitek-karas
Copy link
Member

			string str = GetWithPublicMethods ();
			if (String.Empty.Length == 0) {
				str = GetWithPublicFields (); // dataflow will merge this with the value from the previous basic block
				RequirePublicFields (str); // produces a warning
			}

In the above sample, at the point of calling RequirePublicFields the str local is guaranteed to have the value coming only from GetWithPublicFields(), so it should not warn. But linker doesn't correctly track the values in this case.

There is an existing test case which covers this, but we don't have an issue for it:

[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) }, messageCode: "IL2072")]
public static void TestBranchIf ()
{
string str = GetWithPublicMethods ();
if (String.Empty.Length == 0) {
str = GetWithPublicFields (); // dataflow will merge this with the value from the previous basic block
RequirePublicFields (str); // produces a warning
}
}

vitek-karas added a commit to vitek-karas/linker that referenced this issue Jan 26, 2022
"fixes" a test case in `GetInterface` which was not meant to run into the wrong linker behavior as per bug dotnet#2550
vitek-karas added a commit that referenced this issue Jan 26, 2022
"fixes" a test case in `GetInterface` which was not meant to run into the wrong linker behavior as per bug #2550
agocke pushed a commit to dotnet/runtime that referenced this issue Nov 16, 2022
"fixes" a test case in `GetInterface` which was not meant to run into the wrong linker behavior as per bug dotnet/linker#2550


Commit migrated from dotnet/linker@8fc8c01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant