Skip to content

Commit 53c747d

Browse files
committed
fix function selector as public constant in inheritance
1 parent 19db669 commit 53c747d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

libsolidity/codegen/ir/IRGeneratorForStatements.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,9 +2910,11 @@ void IRGeneratorForStatements::assignInternalFunctionIDIfNotCalledDirectly(
29102910
if (_expression.annotation().calledDirectly)
29112911
return;
29122912

2913-
define(IRVariable(_expression).part("functionIdentifier")) <<
2914-
std::to_string(m_context.mostDerivedContract().annotation().internalFunctionIDs.at(&_referencedFunction)) <<
2915-
"\n";
2913+
auto const it = m_context.mostDerivedContract().annotation().internalFunctionIDs.find(&_referencedFunction);
2914+
if (it == m_context.mostDerivedContract().annotation().internalFunctionIDs.end())
2915+
return;
2916+
2917+
define(IRVariable(_expression).part("functionIdentifier")) << std::to_string(it->second) << '\n';
29162918
m_context.addToInternalDispatch(_referencedFunction);
29172919
}
29182920

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
contract B {
2+
function g() public {}
3+
}
4+
5+
contract C is B {
6+
bytes4 public constant s2 = B.g.selector;
7+
}
8+
9+
10+
// ----
11+
// s2() -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000

0 commit comments

Comments
 (0)