Closed kenji-isuntv closed 7 years ago
This is a minimal failing example:
pragma solidity ^0.4.4;
contract A {
function A() {
if (1 && 1 && 1) {
}
}
}
Apparently the three combined conditions are what trigger the bug. Removing the last && 1
allows solium to run normally.
After a bit more debugging the root of the problem lies in operator-whitespace.js
L21-24
BinaryExpression
s with more than two operands get parsed into a tree where the left
node is itself a BinaryExpression
. This leads to getStringBetweenNodes()
returning an empty string which then breaks in L24.
However I'm not quite sure what the fix should be.
@ulope correct! I'm tracking this through tests (if you run npm test
, you will see 2 operator-whitespace tests failing). To be honest, I myself haven't thought of a solution to this :P
Hopefully, I'll find time to fix this soon!
For now I'm using this truly horrendous brute force hack to work around it. This breaks whitespace violations detection in > 2 operator expressions in some cases but at least avoids the crash.
sed -i '/var strBetweenLeftAndRight/i \
if (node.left.type == "BinaryExpression") { return; }' $(npm root --global)/solium/lib/rules/operator-whitespace.js
solved in v0.2.2, thanks to @kenji-isuntv @ulope @cgewecke
Hopefully it wouldn't pose any more problems (feel free to re-open the issue otherwise) Will keep testing the fix
When I ran the following command:
The result is:
The source code of
BlindAuction.sol
is the same as that in the official tutorial here: