| Index: src/compiler/typer.cc
|
| diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
|
| index 8693b7e1c421887afff2ae7a8c6b408b0b22e7fb..57643c3e1f9882591c09758e34e5643382a083ee 100644
|
| --- a/src/compiler/typer.cc
|
| +++ b/src/compiler/typer.cc
|
| @@ -1537,8 +1537,14 @@ Type* Typer::Visitor::TypeStringFromCharCode(Node* node) {
|
| }
|
|
|
| Type* Typer::Visitor::TypeCheckBounds(Node* node) {
|
| - // TODO(bmeurer): We could do better here based on the limit.
|
| - return Type::Unsigned31();
|
| + Type* index = Operand(node, 0);
|
| + Type* length = Operand(node, 1);
|
| + index = Type::Intersect(index, Type::Integral32(), zone());
|
| + if (!index->IsInhabited() || !length->IsInhabited()) return Type::None();
|
| + double min = std::max(index->Min(), 0.0);
|
| + double max = std::min(index->Max(), length->Min() - 1);
|
| + if (max < min) return Type::None();
|
| + return Type::Range(min, max, zone());
|
| }
|
|
|
| Type* Typer::Visitor::TypeCheckMaps(Node* node) {
|
|
|