aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-02-04 04:34:24 +0800
committerchriseth <c@ethdev.com>2016-02-10 00:07:04 +0800
commit29faf1b298030f23076e8322dafd87df2154b40f (patch)
tree5e2d1d37aac3ab11b3015365a33f945bf9a145aa /libsolidity/analysis
parentfad2d4df222f3fc306eda84a6a3842955541f9d0 (diff)
downloaddexon-solidity-29faf1b298030f23076e8322dafd87df2154b40f.tar.gz
dexon-solidity-29faf1b298030f23076e8322dafd87df2154b40f.tar.zst
dexon-solidity-29faf1b298030f23076e8322dafd87df2154b40f.zip
Index access for bytesXX.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 0d74ddba..756f0e4f 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1253,6 +1253,8 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
arrayType.isDynamicallySized()
);
}
+ else if (exprType->category() == Type::Category::FixedBytes)
+ annotation.isLValue = false;
return false;
}
@@ -1317,6 +1319,22 @@ bool TypeChecker::visit(IndexAccess const& _access)
}
break;
}
+ case Type::Category::FixedBytes:
+ {
+ FixedBytesType const& bytesType = dynamic_cast<FixedBytesType const&>(*baseType);
+ if (!index)
+ typeError(_access.location(), "Index expression cannot be omitted.");
+ else
+ {
+ expectType(*index, IntegerType(256));
+ if (auto integerType = dynamic_cast<IntegerConstantType const*>(type(*index).get()))
+ if (bytesType.numBytes() <= integerType->literalValue(nullptr))
+ typeError(_access.location(), "Out of bounds array access.");
+ }
+ resultType = make_shared<FixedBytesType>(1);
+ isLValue = false; // @todo this heavily depends on how it is embedded
+ break;
+ }
default:
fatalTypeError(
_access.baseExpression().location(),