Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
5edcdf8c
Commit
5edcdf8c
authored
Oct 14, 2019
by
aniket-engg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loop over dynamic array length will show warning
parent
fa772c01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
forLoopIteratesOverDynamicArray.js
...idity-analyzer/modules/forLoopIteratesOverDynamicArray.js
+2
-3
staticAnalysisCommon.js
...zer/src/solidity-analyzer/modules/staticAnalysisCommon.js
+10
-0
No files found.
remix-analyzer/src/solidity-analyzer/modules/forLoopIteratesOverDynamicArray.js
View file @
5edcdf8c
...
...
@@ -8,9 +8,8 @@ function forLoopIteratesOverDynamicArray () {
}
forLoopIteratesOverDynamicArray
.
prototype
.
visit
=
function
(
node
)
{
if
(
common
.
isForLoop
(
node
)
&&
node
.
children
[
1
].
children
[
1
].
attributes
.
member_name
===
'length'
&&
node
.
children
[
1
].
children
[
1
].
children
[
0
].
attributes
.
type
.
indexOf
(
'[]'
)
!==
-
1
)
{
if
(
common
.
isForLoop
(
node
)
&&
(
common
.
isDynamicArrayLengthAccess
(
node
.
children
[
1
].
children
[
1
])
||
(
node
.
children
[
1
].
children
[
1
].
children
&&
common
.
isDynamicArrayLengthAccess
(
node
.
children
[
1
].
children
[
1
].
children
[
0
]))))
{
this
.
relevantNodes
.
push
(
node
)
}
}
...
...
remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js
View file @
5edcdf8c
...
...
@@ -518,6 +518,15 @@ function isDynamicArrayAccess (node) {
}
/**
* True if node accesses 'length' member of array
* @node {ASTNode} node to check for
* @return {bool}
*/
function
isDynamicArrayLengthAccess
(
node
)
{
return
node
&&
nodeType
(
node
,
exactMatch
(
nodeTypes
.
MEMBERACCESS
))
&&
(
node
.
attributes
.
member_name
===
'length'
)
&&
node
.
children
[
0
].
attributes
.
type
.
indexOf
(
'[]'
)
!==
-
1
}
/**
* True if node is a delete instruction for an element from a dynamic array
* @node {ASTNode} node to check for
* @return {bool}
...
...
@@ -1111,6 +1120,7 @@ module.exports = {
isAbiNamespaceCall
:
isAbiNamespaceCall
,
isSpecialVariableAccess
:
isSpecialVariableAccess
,
isDynamicArrayAccess
:
isDynamicArrayAccess
,
isDynamicArrayLengthAccess
:
isDynamicArrayLengthAccess
,
isIndexAccess
:
isIndexAccess
,
isMappingIndexAccess
:
isMappingIndexAccess
,
isSubScopeWithTopLevelUnAssignedBinOp
:
isSubScopeWithTopLevelUnAssignedBinOp
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment