Distinct identifiers and tokens for integer type and integer class

- Using the same name causes syntax ambiguities. It's also not allowed for user-defined classes and types.
This commit is contained in:
Kamil Śliwak 2023-09-19 15:17:35 +02:00
parent 271d55cb04
commit 353d50b0be
4 changed files with 6 additions and 5 deletions

View File

@ -273,7 +273,8 @@ namespace solidity::langutil
K(Class, "class", 0) \
K(Instantiation, "instantiation", 0) \
K(Word, "word", 0) \
K(Integer, "integer", 0) \
K(IntegerType, "integer", 0) \
K(Integer, "Integer", 0) \
K(Itself, "itself", 0) \
K(Void, "void", 0) \
K(Pair, "pair", 0) \
@ -307,7 +308,7 @@ namespace TokenTraits
constexpr bool isElementaryTypeName(Token tok)
{
return (Token::Int <= tok && tok < Token::TypesEnd) ||
tok == Token::Word || tok == Token::Void || tok == Token::Integer ||
tok == Token::Word || tok == Token::Void || tok == Token::IntegerType ||
tok == Token::Pair || tok == Token::Unit || tok == Token::Fun;
}
constexpr bool isAssignmentOp(Token tok) { return Token::Assign <= tok && tok <= Token::AssignMod; }

View File

@ -73,7 +73,7 @@ bool TypeRegistration::visit(ElementaryTypeName const& _typeName)
return m_typeSystem.constructor(PrimitiveType::Pair);
case Token::Word:
return m_typeSystem.constructor(PrimitiveType::Word);
case Token::Integer:
case Token::IntegerType:
return m_typeSystem.constructor(PrimitiveType::Integer);
case Token::Bool:
return m_typeSystem.constructor(PrimitiveType::Bool);

View File

@ -66,7 +66,7 @@ std::optional<TypeConstructor> experimental::typeConstructorFromToken(Analysis c
return typeSystem.builtinConstructor(BuiltinType::Pair);
case Token::Word:
return typeSystem.builtinConstructor(BuiltinType::Word);
case Token::Integer:
case Token::IntegerType:
return typeSystem.builtinConstructor(BuiltinType::Integer);
case Token::Bool:
return typeSystem.builtinConstructor(BuiltinType::Bool);

View File

@ -34,7 +34,7 @@ instantiation word: * {
}
}
instantiation word: integer {
instantiation word: Integer {
function fromInteger(x:integer) -> word {
//x + x;
}