mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
StandardCompiler: Don't assume that link reference always contains a colon
This commit is contained in:
parent
543f804226
commit
b97c6c55ad
@ -323,10 +323,12 @@ Json::Value formatLinkReferences(std::map<size_t, std::string> const& linkRefere
|
|||||||
for (auto const& ref: linkReferences)
|
for (auto const& ref: linkReferences)
|
||||||
{
|
{
|
||||||
string const& fullname = ref.second;
|
string const& fullname = ref.second;
|
||||||
|
|
||||||
|
// If the link reference does not contain a colon, assume that the file name is missing and
|
||||||
|
// the whole string represents the library name.
|
||||||
size_t colon = fullname.rfind(':');
|
size_t colon = fullname.rfind(':');
|
||||||
solAssert(colon != string::npos, "");
|
string file = (colon != string::npos ? fullname.substr(0, colon) : "");
|
||||||
string file = fullname.substr(0, colon);
|
string name = (colon != string::npos ? fullname.substr(colon + 1) : fullname);
|
||||||
string name = fullname.substr(colon + 1);
|
|
||||||
|
|
||||||
Json::Value fileObject = ret.get(file, Json::objectValue);
|
Json::Value fileObject = ret.get(file, Json::objectValue);
|
||||||
Json::Value libraryArray = fileObject.get(name, Json::arrayValue);
|
Json::Value libraryArray = fileObject.get(name, Json::arrayValue);
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
--strict-assembly --libraries L:0x1234567890123456789012345678901234567890
|
@ -0,0 +1 @@
|
|||||||
|
Warning: Yul is still experimental. Please use the output with care.
|
@ -0,0 +1,5 @@
|
|||||||
|
object "a" {
|
||||||
|
code {
|
||||||
|
let addr := linkersymbol("L")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
======= linking_strict_assembly_no_file_name_in_link_reference/input.yul (EVM) =======
|
||||||
|
|
||||||
|
Pretty printed source:
|
||||||
|
object "a" {
|
||||||
|
code { let addr := linkersymbol("L") }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Binary representation:
|
||||||
|
73123456789012345678901234567890123456789050
|
||||||
|
|
||||||
|
Text representation:
|
||||||
|
linkerSymbol("8aa64f937099b65a4febc243a5ae0f2d6416bb9e473c30dd29c1ee498fb7c5a8")
|
||||||
|
/* "linking_strict_assembly_no_file_name_in_link_reference/input.yul":22:67 */
|
||||||
|
pop
|
@ -903,6 +903,70 @@ BOOST_AUTO_TEST_CASE(library_linking)
|
|||||||
expectLinkReferences(contractResult, {{"library2.sol", {"L2"}}});
|
expectLinkReferences(contractResult, {{"library2.sol", {"L2"}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(linking_yul_empty_link_reference)
|
||||||
|
{
|
||||||
|
char const* input = R"(
|
||||||
|
{
|
||||||
|
"language": "Yul",
|
||||||
|
"settings": {
|
||||||
|
"libraries": {
|
||||||
|
"": {
|
||||||
|
"": "0x4200000000000000000000000000000000000001"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputSelection": {
|
||||||
|
"fileA": {
|
||||||
|
"*": [
|
||||||
|
"evm.bytecode.linkReferences"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sources": {
|
||||||
|
"fileA": {
|
||||||
|
"content": "object \"a\" { code { let addr := linkersymbol(\"\") } }"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
Json::Value result = compile(input);
|
||||||
|
BOOST_TEST(containsAtMostWarnings(result));
|
||||||
|
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||||
|
expectLinkReferences(contractResult, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(linking_yul_no_filename_in_link_reference)
|
||||||
|
{
|
||||||
|
char const* input = R"(
|
||||||
|
{
|
||||||
|
"language": "Yul",
|
||||||
|
"settings": {
|
||||||
|
"libraries": {
|
||||||
|
"": {
|
||||||
|
"L": "0x4200000000000000000000000000000000000001"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputSelection": {
|
||||||
|
"fileA": {
|
||||||
|
"*": [
|
||||||
|
"evm.bytecode.linkReferences"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sources": {
|
||||||
|
"fileA": {
|
||||||
|
"content": "object \"a\" { code { let addr := linkersymbol(\"L\") } }"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
Json::Value result = compile(input);
|
||||||
|
BOOST_TEST(containsAtMostWarnings(result));
|
||||||
|
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||||
|
expectLinkReferences(contractResult, {});
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(evm_version)
|
BOOST_AUTO_TEST_CASE(evm_version)
|
||||||
{
|
{
|
||||||
auto inputForVersion = [](string const& _version)
|
auto inputForVersion = [](string const& _version)
|
||||||
|
Loading…
Reference in New Issue
Block a user