mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
StandardCompiler: Include file names in link references
This commit is contained in:
parent
9f0283df5c
commit
4174f38b02
@ -32,6 +32,7 @@ Bugfixes:
|
||||
* SMTChecker: Fix CHC false positives when branches are used inside modifiers.
|
||||
* Code generator: Fix missing creation dependency tracking for abstract contracts.
|
||||
* NatSpec: Fix internal error when inheriting return parameter documentation but the parameter names differ between base and inherited.
|
||||
* Standard JSON: Fix library addresses specified in ``libraries`` being used for linking even if the file names do not match.
|
||||
|
||||
|
||||
### 0.7.4 (2020-10-19)
|
||||
|
@ -839,8 +839,7 @@ std::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompiler:
|
||||
|
||||
try
|
||||
{
|
||||
// @TODO use libraries only for the given source
|
||||
ret.libraries[library] = util::h160(address);
|
||||
ret.libraries[sourceName + ":" + library] = util::h160(address);
|
||||
}
|
||||
catch (util::BadHexCharacter const&)
|
||||
{
|
||||
|
@ -0,0 +1 @@
|
||||
--strict-assembly --libraries library1.sol:L:0x1234567890123456789012345678901234567890
|
@ -0,0 +1 @@
|
||||
Warning: Yul is still experimental. Please use the output with care.
|
@ -0,0 +1,6 @@
|
||||
object "a" {
|
||||
code {
|
||||
let addr1 := linkersymbol("library1.sol:L")
|
||||
let addr2 := linkersymbol("library2.sol:L")
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
|
||||
======= linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul (EVM) =======
|
||||
|
||||
Pretty printed source:
|
||||
object "a" {
|
||||
code {
|
||||
let addr1 := linkersymbol("library1.sol:L")
|
||||
let addr2 := linkersymbol("library2.sol:L")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary representation:
|
||||
73123456789012345678901234567890123456789073__$c3523432985587641d17c68161d2f700c5$__5050
|
||||
|
||||
Text representation:
|
||||
linkerSymbol("f3ffc10c396a7cc41ae954b050792839d20947bf73497d30c49a9fda1ea477ec")
|
||||
/* "linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul":32:75 */
|
||||
linkerSymbol("c3523432985587641d17c68161d2f700c57aaf4ed21cda4f25d76193c831f97f")
|
||||
/* "linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul":22:133 */
|
||||
pop
|
||||
pop
|
@ -903,6 +903,38 @@ BOOST_AUTO_TEST_CASE(library_linking)
|
||||
expectLinkReferences(contractResult, {{"library2.sol", {"L2"}}});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(linking_yul)
|
||||
{
|
||||
char const* input = R"(
|
||||
{
|
||||
"language": "Yul",
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"fileB": {
|
||||
"L": "0x4200000000000000000000000000000000000001"
|
||||
}
|
||||
},
|
||||
"outputSelection": {
|
||||
"fileA": {
|
||||
"*": [
|
||||
"evm.bytecode.linkReferences"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"sources": {
|
||||
"fileA": {
|
||||
"content": "object \"a\" { code { let addr := linkersymbol(\"fileB:L\") } }"
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
Json::Value result = compile(input);
|
||||
BOOST_TEST(containsAtMostWarnings(result));
|
||||
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||
expectLinkReferences(contractResult, {});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(linking_yul_empty_link_reference)
|
||||
{
|
||||
char const* input = R"(
|
||||
@ -932,7 +964,7 @@ BOOST_AUTO_TEST_CASE(linking_yul_empty_link_reference)
|
||||
Json::Value result = compile(input);
|
||||
BOOST_TEST(containsAtMostWarnings(result));
|
||||
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||
expectLinkReferences(contractResult, {});
|
||||
expectLinkReferences(contractResult, {{"", {""}}});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(linking_yul_no_filename_in_link_reference)
|
||||
@ -964,7 +996,39 @@ BOOST_AUTO_TEST_CASE(linking_yul_no_filename_in_link_reference)
|
||||
Json::Value result = compile(input);
|
||||
BOOST_TEST(containsAtMostWarnings(result));
|
||||
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||
expectLinkReferences(contractResult, {});
|
||||
expectLinkReferences(contractResult, {{"", {"L"}}});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(linking_yul_same_library_name_different_files)
|
||||
{
|
||||
char const* input = R"(
|
||||
{
|
||||
"language": "Yul",
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"fileB": {
|
||||
"L": "0x4200000000000000000000000000000000000001"
|
||||
}
|
||||
},
|
||||
"outputSelection": {
|
||||
"fileA": {
|
||||
"*": [
|
||||
"evm.bytecode.linkReferences"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"sources": {
|
||||
"fileA": {
|
||||
"content": "object \"a\" { code { let addr := linkersymbol(\"fileC:L\") } }"
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
Json::Value result = compile(input);
|
||||
BOOST_TEST(containsAtMostWarnings(result));
|
||||
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||
expectLinkReferences(contractResult, {{"fileC", {"L"}}});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(evm_version)
|
||||
|
Loading…
Reference in New Issue
Block a user