duaraghav8 / Ethlint

(Formerly Solium) Code quality & Security Linter for Solidity
https://ethlint.readthedocs.io/en/latest/
MIT License
927 stars 128 forks source link

Syntax error when using array slice on a bytes datatype #284

Open abarmat opened 4 years ago

abarmat commented 4 years ago

Description Syntax error when using array slice on a bytes datatype as allowed in Solidity 0.6

Steps to reproduce

Demo.sol

pragma solidity ^0.6.0;

contract Demo {
    event Log(bytes value);

    function log(bytes calldata value) external {
        emit Log(bytes(value[0:10]));
    }
}

Run with:

solium --dir ./contracts

.soliumrc.json

{
  "extends": "solium:recommended",
  "plugins": ["security"],
  "rules": {
    "no-experimental": ["off"],
    "quotes": ["error", "double"],
    "indentation": ["error", 4],
    "linebreak-style": ["error", "unix"],
    "security/no-inline-assembly": ["off"],
    "security/no-low-level-calls": ["off"]
  }
}

Expected behavior The usage of array slicing on bytes calldata types should not be considered syntax error.

Solidity Documentation https://solidity.readthedocs.io/en/v0.6.0/types.html#array-slices

Operating System MacOS

Linter version 1.2.5

duaraghav8 commented 4 years ago

Thanks for reporting this @abarmat Solidity 0.6 is currently not supported by Ethlint's internal parser, so I can confirm that this is an issue on all platforms.