Skip to content

Commit

Permalink
compiler: Don't crash on erroneous array return types.
Browse files Browse the repository at this point in the history
Another issue with erroneous array types.  When an erroneous array
type is in a function's signature, particularly the return type, we
must guarantee that type is changed into an error type.  Otherwise,
any operations that work on arrays and slices will crash when applied
to the erroneous array return type.

Fixes golang/go#12939.

Change-Id: Ibd2445ad88b5dfd633b8bead0a880586d805bb16
Reviewed-on: https://go-review.googlesource.com/16235
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Jan 27, 2016
1 parent 721c778 commit 9e68d67
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions go/parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ Parse::array_type(bool may_use_ellipsis)
}

Type* element_type = this->type();
if (element_type->is_error_type())
return Type::make_error_type();

return Type::make_array_type(element_type, length);
}
Expand Down

0 comments on commit 9e68d67

Please sign in to comment.