Merge pull request #2392 from crytic/feat/unused-import

feat: add detector for unused imports
pull/2406/head
alpharush 7 months ago committed by GitHub
commit beb3f38045
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      slither/detectors/all_detectors.py
  2. 75
      slither/detectors/statements/unused_import.py
  3. 6
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_C_sol__0.txt
  4. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_ConstantContractLevelUsedInContractTest_sol__0.txt
  5. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_ConstantContractLevelUsedTopLevelTest_sol__0.txt
  6. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_ConstantTopLevelUsedInContractTest_sol__0.txt
  7. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_ConstantTopLevelUsedTopLevelTest_sol__0.txt
  8. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_ContractUsedInContractTest1_sol__0.txt
  9. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_ContractUsedInContractTest2_sol__0.txt
  10. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_ContractUsedTopLevelTest_sol__0.txt
  11. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomErrorTopLevelUsedInContractTest_sol__0.txt
  12. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomEventContractLevelUsedInContractTest_sol__0.txt
  13. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomEventContractLevelUsedTopLevelTest_sol__0.txt
  14. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeContractLevelUsedInContractTest1_sol__0.txt
  15. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeContractLevelUsedInContractTest2_sol__0.txt
  16. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeContractLevelUsedInContractTest3_sol__0.txt
  17. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeContractLevelUsedInContractTest4_sol__0.txt
  18. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeContractLevelUsedTopLevelTest1_sol__0.txt
  19. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeContractLevelUsedTopLevelTest2_sol__0.txt
  20. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeTopLevelUsedInContractTest1_sol__0.txt
  21. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeTopLevelUsedInContractTest2_sol__0.txt
  22. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeTopLevelUsedInContractTest3_sol__0.txt
  23. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeTopLevelUsedInContractTest4_sol__0.txt
  24. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeTopLevelUsedTopLevelTest1_sol__0.txt
  25. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_CustomTypeTopLevelUsedTopLevelTest2_sol__0.txt
  26. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_EnumContractLevelUsedInContractTest_sol__0.txt
  27. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_EnumContractLevelUsedTopLevelTest_sol__0.txt
  28. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_EnumTopLevelUsedInContractTest_sol__0.txt
  29. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_EnumTopLevelUsedTopLevelTest_sol__0.txt
  30. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_FunctionContractLevelUsedInContractTest_sol__0.txt
  31. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_FunctionContractLevelUsedTopLevelTest_sol__0.txt
  32. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_FunctionTopLevelUsedInContractTest_sol__0.txt
  33. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_FunctionTopLevelUsedTopLevelTest_sol__0.txt
  34. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_LibraryUsedInContractTest_sol__0.txt
  35. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_LibraryUsedTopLevelTest_sol__0.txt
  36. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_StructContractLevelUsedInContractTest_sol__0.txt
  37. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_StructContractLevelUsedTopLevelTest_sol__0.txt
  38. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_StructTopLevelUsedInContractTest_sol__0.txt
  39. 0
      tests/e2e/detectors/snapshots/detectors__detector_UnusedImport_0_8_16_StructTopLevelUsedTopLevelTest_sol__0.txt
  40. 10
      tests/e2e/detectors/test_data/unused-import/0.8.16/A.sol
  41. 9
      tests/e2e/detectors/test_data/unused-import/0.8.16/B.sol
  42. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/C.sol
  43. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/C.sol-0.8.16.zip
  44. 7
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantContractLevel.sol
  45. 9
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantContractLevelUsedInContractTest.sol
  46. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantContractLevelUsedInContractTest.sol-0.8.16.zip
  47. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantContractLevelUsedTopLevelTest.sol
  48. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantContractLevelUsedTopLevelTest.sol-0.8.16.zip
  49. 10
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantTopLevel.sol
  50. 9
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantTopLevelUsedInContractTest.sol
  51. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantTopLevelUsedInContractTest.sol-0.8.16.zip
  52. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantTopLevelUsedTopLevelTest.sol
  53. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/ConstantTopLevelUsedTopLevelTest.sol-0.8.16.zip
  54. 7
      tests/e2e/detectors/test_data/unused-import/0.8.16/Contract.sol
  55. 9
      tests/e2e/detectors/test_data/unused-import/0.8.16/ContractUsedInContractTest1.sol
  56. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/ContractUsedInContractTest1.sol-0.8.16.zip
  57. 9
      tests/e2e/detectors/test_data/unused-import/0.8.16/ContractUsedInContractTest2.sol
  58. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/ContractUsedInContractTest2.sol-0.8.16.zip
  59. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/ContractUsedTopLevelTest.sol
  60. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/ContractUsedTopLevelTest.sol-0.8.16.zip
  61. 10
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomErrorTopLevel.sol
  62. 17
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomErrorTopLevelUsedInContractTest.sol
  63. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomErrorTopLevelUsedInContractTest.sol-0.8.16.zip
  64. 7
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomEventContractLevel.sol
  65. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomEventContractLevelUsedInContractTest.sol
  66. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomEventContractLevelUsedInContractTest.sol-0.8.16.zip
  67. 15
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomEventContractLevelUsedTopLevelTest.sol
  68. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomEventContractLevelUsedTopLevelTest.sol-0.8.16.zip
  69. 7
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevel.sol
  70. 9
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedInContractTest1.sol
  71. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedInContractTest1.sol-0.8.16.zip
  72. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedInContractTest2.sol
  73. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedInContractTest2.sol-0.8.16.zip
  74. 13
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedInContractTest3.sol
  75. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedInContractTest3.sol-0.8.16.zip
  76. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedInContractTest4.sol
  77. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedInContractTest4.sol-0.8.16.zip
  78. 15
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedTopLevelTest1.sol
  79. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedTopLevelTest1.sol-0.8.16.zip
  80. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedTopLevelTest2.sol
  81. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeContractLevelUsedTopLevelTest2.sol-0.8.16.zip
  82. 10
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevel.sol
  83. 9
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedInContractTest1.sol
  84. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedInContractTest1.sol-0.8.16.zip
  85. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedInContractTest2.sol
  86. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedInContractTest2.sol-0.8.16.zip
  87. 13
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedInContractTest3.sol
  88. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedInContractTest3.sol-0.8.16.zip
  89. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedInContractTest4.sol
  90. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedInContractTest4.sol-0.8.16.zip
  91. 15
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedTopLevelTest1.sol
  92. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedTopLevelTest1.sol-0.8.16.zip
  93. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedTopLevelTest2.sol
  94. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/CustomTypeTopLevelUsedTopLevelTest2.sol-0.8.16.zip
  95. 10
      tests/e2e/detectors/test_data/unused-import/0.8.16/EnumContractLevel.sol
  96. 9
      tests/e2e/detectors/test_data/unused-import/0.8.16/EnumContractLevelUsedInContractTest.sol
  97. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/EnumContractLevelUsedInContractTest.sol-0.8.16.zip
  98. 12
      tests/e2e/detectors/test_data/unused-import/0.8.16/EnumContractLevelUsedTopLevelTest.sol
  99. BIN
      tests/e2e/detectors/test_data/unused-import/0.8.16/EnumContractLevelUsedTopLevelTest.sol-0.8.16.zip
  100. 13
      tests/e2e/detectors/test_data/unused-import/0.8.16/EnumTopLevel.sol
  101. Some files were not shown because too many files have changed in this diff Show More

@ -98,3 +98,4 @@ from .operations.incorrect_exp import IncorrectOperatorExponentiation
from .statements.tautological_compare import TautologicalCompare
from .statements.return_bomb import ReturnBomb
from .functions.out_of_order_retryable import OutOfOrderRetryable
from .statements.unused_import import UnusedImport

@ -0,0 +1,75 @@
from typing import List
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification, Output
# pylint: disable=protected-access,too-many-nested-blocks
class UnusedImport(AbstractDetector):
"""
Detector unused imports.
"""
ARGUMENT = "unused-import"
HELP = "Detects unused imports"
IMPACT = DetectorClassification.INFORMATIONAL
CONFIDENCE = DetectorClassification.HIGH
WIKI = "https://github.com/crytic/slither/wiki/Detector-Documentation#unused-imports"
WIKI_TITLE = "Unused Imports"
WIKI_DESCRIPTION = "Importing a file that is not used in the contract likely indicates a mistake. The import should be removed until it is needed."
# region wiki_exploit_scenario
WIKI_EXPLOIT_SCENARIO = """
```solidity
import {A} from "./A.sol";
contract B {}
```
B either should import from A and it was forgotten or the import is not needed and should be removed.
"""
# endregion wiki_exploit_scenario
WIKI_RECOMMENDATION = (
"Remove the unused import. If the import is needed later, it can be added back."
)
def _detect(self) -> List[Output]:
results: List[Output] = []
# This is computed lazily and then memoized so we need to trigger the computation.
self.slither._compute_offsets_to_ref_impl_decl()
for unit in self.slither.compilation_units:
for filename, scope in unit.scopes.items():
unused = []
for i in scope.imports:
# `scope.imports` contains all transitive imports so we need to filter out imports not explicitly imported in the file.
# Otherwise, we would recommend removing an import that is used by a leaf contract and cause compilation errors.
if i.scope != scope:
continue
import_path = self.slither.crytic_compile.filename_lookup(i.filename)
use_found = False
# Search through all references to the imported file
for _, refs in self.slither._offset_to_references[import_path].items():
for ref in refs:
# If there is a reference in this file to the imported file, it is used.
if ref.filename == filename:
use_found = True
break
if use_found:
break
if not use_found:
unused.append(f"{i.source_mapping.content} ({i.source_mapping})")
if len(unused) > 0:
unused_list = "\n\t-" + "\n\t-".join(unused)
results.append(
self.generate_result(
[
f"The following unused import(s) in {filename.used} should be removed: {unused_list}\n",
]
)
)
return results

@ -0,0 +1,6 @@
The following unused import(s) in tests/e2e/detectors/test_data/unused-imports/0.8.16/B.sol should be removed:
-import "./A.sol"; (tests/e2e/detectors/test_data/unused-imports/0.8.16/B.sol#4)
The following unused import(s) in tests/e2e/detectors/test_data/unused-imports/0.8.16/C.sol should be removed:
-import "./B.sol"; (tests/e2e/detectors/test_data/unused-imports/0.8.16/C.sol#4)

@ -0,0 +1,10 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
library A
{
function a() public
{
}
}

@ -0,0 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./A.sol";
contract B
{
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./B.sol";
contract C
{
constructor()
{
A.a();
}
}

@ -0,0 +1,7 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
library ConstantContractLevel
{
uint constant public CONSTANT = 0;
}

@ -0,0 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./ConstantContractLevel.sol";
contract ConstantContractLevelUsedInContractTest
{
uint private v = ConstantContractLevel.CONSTANT;
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./ConstantContractLevel.sol";
uint constant __ = ConstantContractLevel.CONSTANT;
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,10 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
uint constant ConstantTopLevel = 0;
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./ConstantTopLevel.sol";
contract ConstantTopLevelUsedInContractTest
{
uint private v = ConstantTopLevel;
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./ConstantTopLevel.sol";
uint constant __ = ConstantTopLevel;
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy_
{
}

@ -0,0 +1,7 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
contract Contract
{
}

@ -0,0 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./Contract.sol";
contract ContractUsedInContractTest1
{
Contract c;
}

@ -0,0 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./Contract.sol";
contract ContractUsedInContractTest2 is Contract
{
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./Contract.sol";
Contract constant c = Contract(address(0x0));
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,10 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
error err();
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,17 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomErrorTopLevel.sol";
contract CustomErrorTopLevelUsedInContractTest
{
constructor()
{
f();
}
function f() private pure
{
revert err();
}
}

@ -0,0 +1,7 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
library CustomEventContractLevel
{
event CustomEvent();
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomEventContractLevel.sol";
contract CustomEventContractLevelUsedInContractTest
{
function f() public
{
emit CustomEventContractLevel.CustomEvent();
}
}

@ -0,0 +1,15 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomEventContractLevel.sol";
function f()
{
emit CustomEventContractLevel.CustomEvent();
}
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,7 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
contract CustomTypeContractLevel
{
type CustomType is uint;
}

@ -0,0 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeContractLevel.sol";
contract CustomTypeContractLevelUsedInContractTest1
{
CustomTypeContractLevel.CustomType private v;
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeContractLevel.sol";
contract CustomTypeContractLevelUsedInContractTest2
{
function f(CustomTypeContractLevel.CustomType) public
{
}
}

@ -0,0 +1,13 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeContractLevel.sol";
contract CustomTypeContractLevelUsedInContractTest3
{
modifier m()
{
CustomTypeContractLevel.CustomType ___;
_;
}
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeContractLevel.sol";
contract CustomTypeContractLevelUsedInContractTest4
{
struct CustomStruct
{
CustomTypeContractLevel.CustomType ___;
}
}

@ -0,0 +1,15 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeContractLevel.sol";
struct CustomTypeContractLevelUsedTopLevelTest1
{
CustomTypeContractLevel.CustomType __;
}
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeContractLevel.sol";
CustomTypeContractLevel.CustomType constant __ = CustomTypeContractLevel.CustomType.wrap(0);
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,10 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
type CustomType is uint;
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeTopLevel.sol";
contract CustomTypeTopLevelUsedInContractTest1
{
CustomType private v;
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeTopLevel.sol";
contract CustomTypeTopLevelUsedInContractTest2
{
function f(CustomType) public
{
}
}

@ -0,0 +1,13 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeTopLevel.sol";
contract CustomTypeTopLevelUsedInContractTest3
{
modifier m()
{
CustomType v;
_;
}
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeTopLevel.sol";
contract CustomTypeTopLevelUsedInContractTest4
{
struct CustomStruct
{
CustomType ___;
}
}

@ -0,0 +1,15 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeTopLevel.sol";
struct CustomTypeTopLevelUsedTopLevelTest1
{
CustomType __;
}
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy_
{
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./CustomTypeTopLevel.sol";
CustomType constant __ = CustomType.wrap(0);
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy_
{
}

@ -0,0 +1,10 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
contract EnumContractLevel
{
enum CustomEnum
{
__
}
}

@ -0,0 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./EnumContractLevel.sol";
contract EnumContractLevelUsedInContractTest
{
uint private v = uint(EnumContractLevel.CustomEnum.__);
}

@ -0,0 +1,12 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
import "./EnumContractLevel.sol";
uint constant __ = uint(EnumContractLevel.CustomEnum.__);
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

@ -0,0 +1,13 @@
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.16;
enum EnumTopLevel
{
__
}
// dummy contract, so that "No contract were found ..." message is not being thrown by Slither
contract Dummy
{
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save