Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-469094: "Inline method" may change semantics for a particular combination of if + return + try + catch

$
0
0
Reporter Jakub Jiricek (jakub.jiricek@vodafone.com) Jakub Jiricek (jakub.jiricek@vodafone.com)
Created Apr 4, 2018 8:51:13 PM
Updated Apr 19, 2018 1:56:12 PM
Subsystem Refactorings - Inplace
Assignee Alisa Afonina (alisa.afonina)
Priority Normal
State Submitted
Type Bug
Fix version No Fix versions
Affected versions 2017.3.5, 2018.1.1
Fixed In Version ReSharper Undefined
VsVersion All Versions
in the following example,
    public void resharperTest1(int i)
{
int x = resharperTest2(i);
}

private int resharperTest2(int i)
{
try
{
if (i == 1) return 1;
return 2;
}
catch (Exception e)
{
return 3;
}
}

when I use "inline method" on resharperTest2() I get

    public void resharperTest1(int i)
{
int ret;
try
{
if (i == 1) ret = 1; //<---here is the bug
ret = 2;
}
catch (Exception e)
{
ret = 3;
}

int x = ret;
}
which is incorrect, as the ret=1 assignment is always overwritten by ret=2.

for a similar code without the try-catch block Resharper says it cannot inline the method so no problem is created in that case.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>