mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6604 from ethereum/library-self-delegatecall
Error on library calling itself externally
This commit is contained in:
commit
e9f41d1148
@ -1,6 +1,7 @@
|
|||||||
### 0.5.9 (unreleased)
|
### 0.5.9 (unreleased)
|
||||||
|
|
||||||
Language Features:
|
Language Features:
|
||||||
|
* Static Analyzer: Disallow libraries calling themselves externally.
|
||||||
|
|
||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
|
@ -309,6 +309,19 @@ bool StaticAnalyzer::visit(FunctionCall const& _functionCall)
|
|||||||
"Arithmetic modulo zero."
|
"Arithmetic modulo zero."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
m_currentContract->isLibrary() &&
|
||||||
|
functionType->kind() == FunctionType::Kind::DelegateCall &&
|
||||||
|
functionType->declaration().scope() == m_currentContract
|
||||||
|
)
|
||||||
|
m_errorReporter.typeError(
|
||||||
|
_functionCall.location(),
|
||||||
|
SecondarySourceLocation().append(
|
||||||
|
"The function declaration is here:",
|
||||||
|
functionType->declaration().scope()->location()
|
||||||
|
),
|
||||||
|
"Libraries cannot call their own functions externally."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
library L1 {
|
||||||
|
using L1 for *;
|
||||||
|
function f() public pure returns (uint r) { return r.g(); }
|
||||||
|
function g(uint) public pure returns (uint) { return 2; }
|
||||||
|
}
|
||||||
|
|
||||||
|
library L2 {
|
||||||
|
using L1 for *;
|
||||||
|
function f() public pure returns (uint r) { return r.g(); }
|
||||||
|
function g(uint) public pure returns (uint) { return 2; }
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError: (88-93): Libraries cannot call their own functions externally.
|
Loading…
Reference in New Issue
Block a user