Skip to content

Commit

Permalink
Disabled error on missing instruction
Browse files Browse the repository at this point in the history
Fixes #2115

(cherry picked from commit d9e8924)
  • Loading branch information
hurricup committed Sep 5, 2019
1 parent 185d80c commit 22e387c
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ private static PerlValue getValueFromControlFlow(@NotNull PsiElement element,
elementInstructionIndex = PerlControlFlowBuilder.findInstructionNumberByRange(instructions, elementToFind);
}
if (elementInstructionIndex < 0) {
LOG.error("Unable to find an instruction for " +
element.getClass() + "; " +
element.getText() + "; " +
element.getTextRange() + "; " +
PsiUtilCore.getVirtualFile(element) + "; " +
controlFlowScope.getClass() + "; " +
PerlUtil.getParentsChain(element));
LOG.warn("Unable to find an instruction for " +
element.getClass() + "; " +
element.getText() + "; " +
element.getTextRange() + "; " +
PsiUtilCore.getVirtualFile(element) + "; " +
controlFlowScope.getClass() + "; " +
PerlUtil.getParentsChain(element));
return UNKNOWN_VALUE;
}
int currentInstructionIndex = elementInstructionIndex;
Expand Down
3 changes: 3 additions & 0 deletions plugin/test/unit/perl/PerlControlFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ protected String getBaseDataPath() {
return "testData/unit/perl/controlFlow";
}

@Test
public void testIssue2115() {doTestControlFlow(false);}

@Test
public void testSwitch() {
PerlSharedSettings.getInstance(getProject()).PERL_SWITCH_ENABLED = true;
Expand Down
3 changes: 3 additions & 0 deletions plugin/test/unit/perl/PerlValuesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ protected String getBaseDataPath() {
return "testData/unit/perl/perlValues";
}

@Test
public void testIssue2115() {doTest();}

@Test
public void testBareLpCodeBlock() {doTest();}

Expand Down
15 changes: 15 additions & 0 deletions plugin/testData/unit/perl/controlFlow/issue2115.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


sub something{

my $var;

foreach $a (@VAR) {
{
if( $a ){
foreach @{[foo($v<caret>ar)];}
}
}
}
}

13 changes: 13 additions & 0 deletions plugin/testData/unit/perl/controlFlow/issue2115.pl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
0(1) element: null (InstructionImpl)
1(2) element: PsiPerlSubDefinitionImpl(SUB_DEFINITION)@main::something (InstructionImpl)
2(3) element: PsiPerlScalarVariableImpl(Perl5: SCALAR_VARIABLE) (InstructionImpl)
3(4) element: PsiPerlVariableDeclarationElementImpl(VARIABLE_DECLARATION_ELEMENT) (InstructionImpl)
4(5) element: PsiPerlVariableDeclarationLexicalImpl(Perl5: VARIABLE_DECLARATION_LEXICAL) (InstructionImpl)
5(6) element: PsiPerlArrayVariableImpl(Perl5: ARRAY_VARIABLE) (InstructionImpl)
6(7,12) iterate PsiPerlConditionExprImpl(Perl5: CONDITION_EXPR) using PsiPerlForeachIteratorImpl(Perl5: FOREACH_ITERATOR) (PerlIterateInstruction)
7(8) element: PsiPerlConditionExprImpl(Perl5: CONDITION_EXPR). Condition: (@VAR):true (PerlIteratorConditionInstruction)
8(9,6) element: PsiPerlScalarVariableImpl(Perl5: SCALAR_VARIABLE) (InstructionImpl)
9(10) element: PsiPerlConditionExprImpl(Perl5: CONDITION_EXPR). Condition: ( $a ):true (ConditionalInstructionImpl)
10(11,6) iterate null using PsiPerlForeachIteratorImpl(Perl5: FOREACH_ITERATOR) (PerlIterateInstruction)
11(10) element: null. Condition: null:true (PerlIteratorConditionInstruction)
12() element: null (InstructionImpl)
15 changes: 15 additions & 0 deletions plugin/testData/unit/perl/perlValues/issue2115.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


sub something{

my $var;

foreach $a (@VAR) {
{
if( $a ){
foreach @{[foo($v<caret>ar)];}
}
}
}
}

20 changes: 20 additions & 0 deletions plugin/testData/unit/perl/perlValues/issue2115.pl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
sub something{

my $var;

foreach $a (@VAR) {
{
if( $a ){
foreach @{[foo($v<caret>ar)];}
}
}
}
}
----------
$var
PsiPerlScalarVariableImpl(Perl5: SCALAR_VARIABLE) at 119 in issue2115.pl
Value unknown
----------
Resolved
----------
Value unknown

0 comments on commit 22e387c

Please sign in to comment.