mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix import directive visits in type checker and view pure checker.
This commit is contained in:
parent
3f6beaa0ad
commit
0f1a63c3fa
@ -14,6 +14,7 @@ Compiler Features:
|
|||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
* General: Fix internal error for locales with unusual capitalization rules. Locale set in the environment is now completely ignored.
|
* General: Fix internal error for locales with unusual capitalization rules. Locale set in the environment is now completely ignored.
|
||||||
|
* Type Checker: Fix incorrect type checker errors when importing overloaded functions.
|
||||||
* Yul IR Code Generation: Optimize embedded creation code with correct settings. This fixes potential mismatches between the constructor code of a contract compiled in isolation and the bytecode in ``type(C).creationCode``, resp. the bytecode used for ``new C(...)``.
|
* Yul IR Code Generation: Optimize embedded creation code with correct settings. This fixes potential mismatches between the constructor code of a contract compiled in isolation and the bytecode in ``type(C).creationCode``, resp. the bytecode used for ``new C(...)``.
|
||||||
|
|
||||||
|
|
||||||
|
@ -268,6 +268,11 @@ TypePointers TypeChecker::typeCheckMetaTypeFunctionAndRetrieveReturnType(Functio
|
|||||||
return {TypeProvider::meta(dynamic_cast<TypeType const&>(*firstArgType).actualType())};
|
return {TypeProvider::meta(dynamic_cast<TypeType const&>(*firstArgType).actualType())};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TypeChecker::visit(ImportDirective const&)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
||||||
{
|
{
|
||||||
auto base = dynamic_cast<ContractDefinition const*>(&dereference(_inheritance.name()));
|
auto base = dynamic_cast<ContractDefinition const*>(&dereference(_inheritance.name()));
|
||||||
|
@ -125,6 +125,8 @@ private:
|
|||||||
FunctionType const* _functionType
|
FunctionType const* _functionType
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool visit(ImportDirective const&) override;
|
||||||
|
|
||||||
void endVisit(InheritanceSpecifier const& _inheritance) override;
|
void endVisit(InheritanceSpecifier const& _inheritance) override;
|
||||||
void endVisit(ModifierDefinition const& _modifier) override;
|
void endVisit(ModifierDefinition const& _modifier) override;
|
||||||
bool visit(FunctionDefinition const& _function) override;
|
bool visit(FunctionDefinition const& _function) override;
|
||||||
|
@ -134,6 +134,11 @@ bool ViewPureChecker::check()
|
|||||||
return !m_errors;
|
return !m_errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ViewPureChecker::visit(ImportDirective const&)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool ViewPureChecker::visit(FunctionDefinition const& _funDef)
|
bool ViewPureChecker::visit(FunctionDefinition const& _funDef)
|
||||||
{
|
{
|
||||||
solAssert(!m_currentFunction, "");
|
solAssert(!m_currentFunction, "");
|
||||||
|
@ -50,6 +50,8 @@ private:
|
|||||||
langutil::SourceLocation location;
|
langutil::SourceLocation location;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool visit(ImportDirective const&) override;
|
||||||
|
|
||||||
bool visit(FunctionDefinition const& _funDef) override;
|
bool visit(FunctionDefinition const& _funDef) override;
|
||||||
void endVisit(FunctionDefinition const& _funDef) override;
|
void endVisit(FunctionDefinition const& _funDef) override;
|
||||||
bool visit(ModifierDefinition const& _modifierDef) override;
|
bool visit(ModifierDefinition const& _modifierDef) override;
|
||||||
|
@ -115,6 +115,12 @@ void SMTEncoder::endVisit(ContractDefinition const& _contract)
|
|||||||
m_context.popSolver();
|
m_context.popSolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SMTEncoder::visit(ImportDirective const&)
|
||||||
|
{
|
||||||
|
// do not visit because the identifier therein will confuse us.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SMTEncoder::endVisit(VariableDeclaration const& _varDecl)
|
void SMTEncoder::endVisit(VariableDeclaration const& _varDecl)
|
||||||
{
|
{
|
||||||
// State variables are handled by the constructor.
|
// State variables are handled by the constructor.
|
||||||
|
@ -136,6 +136,7 @@ protected:
|
|||||||
// because the order of expression evaluation is undefined
|
// because the order of expression evaluation is undefined
|
||||||
// TODO: or just force a certain order, but people might have a different idea about that.
|
// TODO: or just force a certain order, but people might have a different idea about that.
|
||||||
|
|
||||||
|
bool visit(ImportDirective const& _node) override;
|
||||||
bool visit(ContractDefinition const& _node) override;
|
bool visit(ContractDefinition const& _node) override;
|
||||||
void endVisit(ContractDefinition const& _node) override;
|
void endVisit(ContractDefinition const& _node) override;
|
||||||
void endVisit(VariableDeclaration const& _node) override;
|
void endVisit(VariableDeclaration const& _node) override;
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
==== Source: A ====
|
||||||
|
function sub(uint256 x, uint256 y) pure returns (uint) { return 1; }
|
||||||
|
function sub(uint256 x) pure returns (uint) { return 2; }
|
||||||
|
==== Source: B ====
|
||||||
|
import {sub} from "A";
|
||||||
|
contract C
|
||||||
|
{
|
||||||
|
function f() public pure returns (uint, uint) {
|
||||||
|
return (sub(1, 2), sub(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// f() -> 1, 2
|
Loading…
Reference in New Issue
Block a user