Skip to content

Commit

Permalink
#284 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaneberly committed Jun 16, 2017
1 parent a7015db commit f72821c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/main/java/com/cflint/CFLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,20 @@ private void process(final CFExpression expression, final Element elem, Context
if(context.isInAssignmentExpression() && new CFScopes().isScoped(fullVarExpression,"local") && fullVarExpression.getExpressions().size()>1){
handler.addVariable(fullVarExpression.getExpressions().get(1).Decompile(0));
}
Context subContext = context.subContext(context.getElement());
subContext.setInAssignmentExpression(false);
for (final CFExpression expr : fullVarExpression.getExpressions()) {
if (expr instanceof CFFunctionExpression) {
process(expr, elem, context);
process(expr, elem, subContext);
}
if (expr instanceof CFMember){
process(((CFMember) expr).getExpression(), elem, context);
process(((CFMember) expr).getExpression(), elem, subContext);
}
if (expr instanceof CFArrayExpression){
CFArrayExpression aryExpr = (CFArrayExpression)expr;
if(aryExpr.getElements().size()>0){
process(aryExpr.getElements().get(0), elem, subContext);
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<cfloop query="local.something">
<cfscript>
variables.siteDetailList[siteID] = 123;
siteID = 123;
</cfscript>
</cfloop>
<cfset siteID=1/>
Expand Down
10 changes: 10 additions & 0 deletions src/test/resources/com/cflint/tests/VarScoper/structassignment.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<cfcomponent>
<cffunction name="foo">
<cfscript>
var siteDetail={};
foobar.foo.xyz.[siteID] = 123;
siteDetail.foo.xyz.[siteID] = 123;
</cfscript>
</cfloop>
</cffunction>
</cfcomponent>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ ]

0 comments on commit f72821c

Please sign in to comment.