Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow function parameter name to be empty when casting to string #2158

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion slither/core/variables/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,4 @@ def solidity_signature(self) -> str:
return f'{name}({",".join(parameters)})'

def __str__(self) -> str:
0xalpharush marked this conversation as resolved.
Show resolved Hide resolved
assert self._name
return self._name
0xalpharush marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
contract TestSlither {
function testFunction(uint256 param1, uint256, address param3) public {

}
}
15 changes: 15 additions & 0 deletions tests/e2e/compilation/test_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,18 @@ def test_cycle(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.0")
slither = Slither(Path(TEST_DATA_DIR, "test_cyclic_import", "a.sol").as_posix(), solc=solc_path)
_run_all_detectors(slither)


def test_contract_function_parameter(solc_binary_path) -> None:
solc_path = solc_binary_path("0.8.0")
standard_json = SolcStandardJson()
standard_json.add_source_file(
Path(TEST_DATA_DIR, "test_contract_data", "test_contract_data.sol").as_posix()
)
compilation = CryticCompile(standard_json, solc=solc_path)
slither = Slither(compilation)
contract = slither.contracts[0]

for function in contract.functions:
for parameter in function.parameters:
str(parameter)
dokzai marked this conversation as resolved.
Show resolved Hide resolved