mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol -> Yul] Enable function pointer comparison
This commit is contained in:
parent
e5902c58a4
commit
81702717b0
@ -356,7 +356,12 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
|
||||
"\n";
|
||||
else if (TokenTraits::isCompareOp(op))
|
||||
{
|
||||
solUnimplementedAssert(commonType->category() != Type::Category::Function, "");
|
||||
if (auto type = dynamic_cast<FunctionType const*>(commonType))
|
||||
{
|
||||
solAssert(op == Token::Equal || op == Token::NotEqual, "Invalid function pointer comparison!");
|
||||
solAssert(type->kind() != FunctionType::Kind::External, "External function comparison not allowed!");
|
||||
}
|
||||
|
||||
solAssert(commonType->isValueType(), "");
|
||||
bool isSigned = false;
|
||||
if (auto type = dynamic_cast<IntegerType const*>(commonType))
|
||||
|
@ -0,0 +1,23 @@
|
||||
contract C {
|
||||
function internal1() internal pure returns (bool) {
|
||||
return true;
|
||||
}
|
||||
function internal2() internal pure returns (bool) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function equal() public pure returns (bool same, bool diff) {
|
||||
same = internal1 == internal1;
|
||||
diff = internal1 == internal2;
|
||||
}
|
||||
|
||||
function unequal() public pure returns (bool same, bool diff) {
|
||||
same = internal1 != internal1;
|
||||
diff = internal1 != internal2;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// equal() -> true, false
|
||||
// unequal() -> false, true
|
Loading…
Reference in New Issue
Block a user