mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
added fix and a test for order independence of nested prefixing
Signed-off-by: VoR0220 <rj@erisindustries.com>
This commit is contained in:
parent
4585bfdce7
commit
4542f459f1
@ -523,7 +523,7 @@ string CompilerStack::applyRemapping(string const& _path, string const& _context
|
|||||||
if (!isPrefixOf(context, _context))
|
if (!isPrefixOf(context, _context))
|
||||||
continue;
|
continue;
|
||||||
// Skip if we already have a closer prefix match.
|
// Skip if we already have a closer prefix match.
|
||||||
if (prefix.length() < longestPrefix)
|
if (prefix.length() < longestPrefix && context.length() == longestContext)
|
||||||
continue;
|
continue;
|
||||||
// Skip if the prefix does not match.
|
// Skip if the prefix does not match.
|
||||||
if (!isPrefixOf(prefix, _path))
|
if (!isPrefixOf(prefix, _path))
|
||||||
@ -534,7 +534,7 @@ string CompilerStack::applyRemapping(string const& _path, string const& _context
|
|||||||
bestMatchTarget = redir.target;
|
bestMatchTarget = redir.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
string path = longestPrefixTarget;
|
string path = bestMatchTarget;
|
||||||
path.append(_path.begin() + longestPrefix, _path.end());
|
path.append(_path.begin() + longestPrefix, _path.end());
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,24 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_ensure_default_and_module_pres
|
|||||||
BOOST_CHECK(c.compile());
|
BOOST_CHECK(c.compile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(context_dependent_remappings_order_independent)
|
||||||
|
{
|
||||||
|
CompilerStack c;
|
||||||
|
c.setRemappings(vector<string>{"a:x/y/z=d", "a/b:x=e"});
|
||||||
|
c.addSource("a/main.sol", "import \"x/y/z/z.sol\"; contract Main is D {} pragma solidity >=0.0;");
|
||||||
|
c.addSource("a/b/main.sol", "import \"x/y/z/z.sol\"; contract Main is E {} pragma solidity >=0.0;");
|
||||||
|
c.addSource("x/y/z/z.sol", "contract D {} pragma solidity >=0.0;");
|
||||||
|
c.addSource("e/y/z/z.sol", "contract E {} pragma solidity >=0.0;");
|
||||||
|
BOOST_CHECK(c.compile());
|
||||||
|
CompilerStack d;
|
||||||
|
d.setRemappings(vector<string>{"a/b:x=e", "a:x/y/z=d"});
|
||||||
|
d.addSource("a/main.sol", "import \"x/y/z/z.sol\"; contract Main is D {} pragma solidity >=0.0;");
|
||||||
|
d.addSource("a/b/main.sol", "import \"x/y/z/z.sol\"; contract Main is E {} pragma solidity >=0.0;");
|
||||||
|
d.addSource("x/y/z/z.sol", "contract D {} pragma solidity >=0.0;");
|
||||||
|
d.addSource("e/y/z/z.sol", "contract E {} pragma solidity >=0.0;");
|
||||||
|
BOOST_CHECK(d.compile());
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user