diff --git a/crytic_compile/platform/standard.py b/crytic_compile/platform/standard.py index ed01936d..19669ff5 100644 --- a/crytic_compile/platform/standard.py +++ b/crytic_compile/platform/standard.py @@ -452,7 +452,7 @@ def _load_from_compile_current(crytic_compile: "CryticCompile", loaded_json: Dic filename = compilation_unit.filename_lookup(filename_str) source_unit = compilation_unit.create_source_unit(filename) - for contract_name, contract in source_unit_data["contracts"].items(): + for contract_name, contract in source_unit_data.get("contracts", {}).items(): compilation_unit.filename_to_contracts[filename].add(contract_name) source_unit = compilation_unit.create_source_unit(filename) diff --git a/scripts/ci_test_standard.sh b/scripts/ci_test_standard.sh index c983f2e7..281087f4 100755 --- a/scripts/ci_test_standard.sh +++ b/scripts/ci_test_standard.sh @@ -2,10 +2,13 @@ DIR=$(mktemp -d) -cp tests/contract.sol "$DIR" +cp tests/contract_with_toplevel.sol "$DIR" +cp tests/toplevel.sol "$DIR" cd "$DIR" || exit 255 -crytic-compile contract.sol --export-format archive +solc-select use 0.8.0 --always-install + +crytic-compile contract_with_toplevel.sol --export-format archive if [ $? -ne 0 ] then @@ -13,7 +16,7 @@ then exit 255 fi -crytic-compile crytic-export/contract.sol_export_archive.json +crytic-compile crytic-export/contract_with_toplevel.sol_export_archive.json if [ $? -ne 0 ] then @@ -22,7 +25,7 @@ then fi -crytic-compile contract.sol --export-zip test.zip +crytic-compile contract_with_toplevel.sol --export-zip test.zip if [ $? -ne 0 ] then diff --git a/tests/contract_with_toplevel.sol b/tests/contract_with_toplevel.sol new file mode 100644 index 00000000..0e1155d5 --- /dev/null +++ b/tests/contract_with_toplevel.sol @@ -0,0 +1,7 @@ +import "./toplevel.sol"; + +contract C{ + function f() external{ + + } +} diff --git a/tests/toplevel.sol b/tests/toplevel.sol new file mode 100644 index 00000000..2c82f464 --- /dev/null +++ b/tests/toplevel.sol @@ -0,0 +1,3 @@ +function g(){ + +} \ No newline at end of file