Skip to content

Commit

Permalink
0.74.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorKoval committed Apr 10, 2024
1 parent 82d8855 commit 18978e6
Show file tree
Hide file tree
Showing 74 changed files with 5,018 additions and 3,053 deletions.
764 changes: 474 additions & 290 deletions API.md

Large diffs are not rendered by default.

233 changes: 115 additions & 118 deletions Cargo.lock

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
### 0.74.0 (2024-04-11)

Breaking changes:
* Now `int` is alias for `int257`, not for `int256`. That's why `*loadInt*` functions return `int257` and `*storeInt*` functions take `int257`.
* Deleted debots supporting.
* Now [vector](API.md#vectort) can contain at least 255 elements.

Bugfixes:
* Fixed minor bugs in TypeChecker.
* Fixed compilation fail when you have private and public functions with the same name in the contract.
* Fixed another minor bugs.

Compiler features:
* Supported [quiet arithmetic](./API.md#quiet-arithmetic).
* Supported [StringBuilder](./API.md#stringbuilder).
* Supported [int257](API.md#integers).
* Supported [\<vector(T)\>.last()](API.md#vectortlast).
* Supported [stack(T)](API.md#stackt).
* Supported unary operators (`++`, `--`, `-`, `delete` and `~`) for [varint and varuint](API.md#varint-and-varuint).
* Supported [Free function call via object](API.md#free-function-call-via-object).

Other changes:
* Renamed some types. Old types are available and marked as deprecated. Renaming:
* `varInt` -> `varint`
* `varUint` -> `varuint`
* `varIntM` -> `varintM`
* `varUintM` -> `varuintM`

### 0.73.0 (2024-02-12)

Update compiler frontend (from original version 0.8.17 to 0.8.24). Full changelog can be found [here](./compiler/Changelog.md).
Expand Down
2 changes: 1 addition & 1 deletion compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include(EthPolicy)
eth_policy()

# project name and version should be set after cmake_policy CMP0048
set(PROJECT_VERSION "0.73.0")
set(PROJECT_VERSION "0.74.0")
# OSX target needed in order to support std::visit
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
Expand Down
36 changes: 33 additions & 3 deletions compiler/liblangutil/Token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,28 @@ void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _fi
"No elementary type " + std::string(TokenTraits::toString(_baseType)) + std::to_string(_first) + "."
);
}
else if (_baseType == Token::QUIntM || _baseType == Token::QIntM)
{
unsigned bitLength = _baseType == Token::QUIntM ? 256 : 257;
solAssert(_second == 0, "There should not be a second size argument to type " + std::string(TokenTraits::toString(_baseType)) + ".");
solAssert(
_first <= bitLength,
"No elementary type " + std::string(TokenTraits::toString(_baseType)) + std::to_string(_first) + "."
);
}
else if (_baseType == Token::QBool)
{
// all right
}
else if (_baseType == Token::UFixedMxN || _baseType == Token::FixedMxN)
{
solAssert(
_first >= 8 && _first <= 256 && _second <= 80,
"No elementary type " + std::string(TokenTraits::toString(_baseType)) + std::to_string(_first) + "x" + std::to_string(_second) + "."
);
}
else if (_baseType == Token::VarUintM || _baseType == Token::VarIntM)
else if (_baseType == Token::VarUintM || _baseType == Token::VarIntM ||
_baseType == Token::VarUintM2 || _baseType == Token::VarIntM2)
{
solAssert(_first == 16 || _first == 32, "");
}
Expand Down Expand Up @@ -194,9 +208,10 @@ std::tuple<Token, unsigned int, unsigned int> fromIdentifierOrKeyword(std::strin
Token keyword = keywordByName(baseType);


if (keyword == Token::VarUint || keyword == Token::VarInt) {
if (keyword == Token::VarUint || keyword == Token::VarInt ||
keyword == Token::VarUint2 || keyword == Token::VarInt2) {
if (m == 16 || m == 32) {
if (keyword == Token::VarUint)
if (keyword == Token::VarUint || keyword == Token::VarUint2)
return std::make_tuple(Token::VarUintM, m, 0);
return std::make_tuple(Token::VarIntM, m, 0);
}
Expand All @@ -217,6 +232,21 @@ std::tuple<Token, unsigned int, unsigned int> fromIdentifierOrKeyword(std::strin
return std::make_tuple(Token::IntM, m, 0);
}
}
else if (keyword == Token::QUInt || keyword == Token::QInt)
{
int bitLength = keyword == Token::QUInt ? 256 : 257;
if (0 < m && m <= bitLength && positionX == _literal.end())
{
if (keyword == Token::QUInt)
return std::make_tuple(Token::QUIntM, m, 0);
else
return std::make_tuple(Token::QIntM, m, 0);
}
}
else if (keyword == Token::QBool)
{
return std::make_tuple(Token::QBool, 0, 0);
}
else if (keyword == Token::UFixed || keyword == Token::Fixed)
{
if (
Expand Down
16 changes: 13 additions & 3 deletions compiler/liblangutil/Token.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ namespace solidity::langutil
K(Anonymous, "anonymous", 0) \
K(As, "as", 0) \
K(Assembly, "assembly", 0) \
K(Await, "await", 0) \
K(Break, "break", 0) \
K(Catch, "catch", 0) \
K(Constant, "constant", 0) \
Expand All @@ -157,7 +156,6 @@ namespace solidity::langutil
K(Emit, "emit", 0) \
K(Event, "event", 0) \
K(External, "external", 0) \
K(ExtMsg, "extMsg", 0) \
K(Fallback, "fallback", 0) \
K(onBounce, "onBounce", 0) \
K(For, "for", 0) \
Expand All @@ -180,6 +178,7 @@ namespace solidity::langutil
K(NoStorage, "nostorage", 0) \
K(Optional, "optional", 0) \
K(TvmVector, "vector", 0) \
K(TvmStack, "stack", 0) \
K(Override, "override", 0) \
K(Payable, "payable", 0) \
K(Public, "public", 0) \
Expand Down Expand Up @@ -239,26 +238,36 @@ namespace solidity::langutil
/* type keywords*/ \
K(Int, "int", 0) \
K(UInt, "uint", 0) \
K(QInt, "qint", 0) \
K(QUInt, "quint", 0) \
K(QBool, "qbool", 0) \
K(Bytes, "bytes", 0) \
K(String, "string", 0) \
K(Address, "address", 0) \
K(Bool, "bool", 0) \
K(TvmCell, "TvmCell", 0) \
K(TvmSlice, "TvmSlice", 0) \
K(TvmBuilder, "TvmBuilder", 0) \
K(StringBuilder, "StringBuilder", 0) \
K(Variant, "variant", 0) \
K(Fixed, "fixed", 0) \
K(UFixed, "ufixed", 0) \
T(IntM, "intM", 0) \
T(UIntM, "uintM", 0) \
T(QIntM, "qintM", 0) \
T(QUIntM, "quintM", 0) \
T(BytesM, "bytesM", 0) \
T(FixedMxN, "fixedMxN", 0) \
T(UFixedMxN, "ufixedMxN", 0) \
K(VarInt, "varInt", 0) \
K(VarInt2, "varint", 0) \
T(VarIntM, "varIntM", 0) \
T(VarIntM2, "varintM", 0) \
K(VarUint, "varUint", 0) \
K(coins, "coins", 0) \
K(VarUint2, "varuint", 0) \
T(VarUintM, "varUintM", 0) \
T(VarUintM2, "varuintM", 0) \
K(coins, "coins", 0) \
T(TypesEnd, nullptr, 0) /* used as type enum end marker */ \
\
/* Literals */ \
Expand Down Expand Up @@ -293,6 +302,7 @@ namespace solidity::langutil
K(Mutable, "mutable", 0) \
K(NullLiteral, "null", 0) \
K(EmptyMap, "emptyMap", 0) \
K(TVMNaN, "NaN", 0) \
K(Of, "of", 0) \
K(Partial, "partial", 0) \
K(Promise, "promise", 0) \
Expand Down
17 changes: 16 additions & 1 deletion compiler/libsolidity/analysis/DeclarationTypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,16 @@ void DeclarationTypeChecker::endVisit(TvmVector const& _tvmVector)
return;

TypeName const& type = _tvmVector.type();
_tvmVector.annotation().type = TypeProvider::tvmtuple(type.annotation().type);
_tvmVector.annotation().type = TypeProvider::tvmVector(type.annotation().type);
}

void DeclarationTypeChecker::endVisit(TvmStack const& _tvmStack)
{
if (_tvmStack.annotation().type)
return;

TypeName const& type = _tvmStack.type();
_tvmStack.annotation().type = TypeProvider::tvmStack(type.annotation().type);
}

void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
Expand Down Expand Up @@ -380,6 +389,12 @@ bool DeclarationTypeChecker::visit(UsingForDirective const& _usingFor)
for (ASTPointer<IdentifierPath> const& function: _usingFor.functionsOrLibrary())
if (auto functionDefinition = dynamic_cast<FunctionDefinition const*>(function->annotation().referencedDeclaration))
{
if (functionDefinition->isInlineAssembly())
m_errorReporter.typeError(
1167_error,
function->location(),
"Only file-level functions (not assembly) and library functions can be attached to a type in a \"using\" statement."
);
if (!functionDefinition->isFree() && !(
dynamic_cast<ContractDefinition const*>(functionDefinition->scope()) &&
dynamic_cast<ContractDefinition const*>(functionDefinition->scope())->isLibrary()
Expand Down
1 change: 1 addition & 0 deletions compiler/libsolidity/analysis/DeclarationTypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class DeclarationTypeChecker: private ASTConstVisitor
void endVisit(Mapping const& _mapping) override;
void endVisit(Optional const& _optional) override;
void endVisit(TvmVector const& _tvmVector) override;
void endVisit(TvmStack const& _tvmStack) override;
void endVisit(ArrayTypeName const& _typeName) override;
void endVisit(VariableDeclaration const& _variable) override;
bool visit(EnumDefinition const& _enum) override;
Expand Down
5 changes: 4 additions & 1 deletion compiler/libsolidity/analysis/SyntaxChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
" to set a version of the compiler.";
m_errorReporter.warning(6413_error, _pragma.location(), errorString);
}
else if (_pragma.literals()[0] == "ever" || _pragma.literals()[0] == "ton") // ever-solidity
else if (_pragma.literals()[0] == "ever" || _pragma.literals()[0] == "ton" || _pragma.literals()[0] == "tvm")
{
if (m_versionPragma.has_value()) {
m_errorReporter.fatalTypeError(
Expand Down Expand Up @@ -480,6 +480,9 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
// Handled in experimental::SyntaxRestrictor instead.
return true;

if (!_function.isFree() && _function.isInlineAssembly())
m_errorReporter.fatalTypeError(7229_error, _function.location(), "Only free functions can be marked as \"assembly\".");

if (!_function.isFree() && !_function.isConstructor() && _function.noVisibilitySpecified())
{
std::string suggestedVisibility =
Expand Down
Loading

0 comments on commit 18978e6

Please sign in to comment.