Skip to content

Commit

Permalink
compiler: Don't crash on erroneous channel reads.
Browse files Browse the repository at this point in the history
Fixes golang/go#12320.

Change-Id: I58f1ef605fc7200319c45f87673198c4c989fd09
Reviewed-on: https://go-review.googlesource.com/13932
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
Chris Manghane authored and ianlancetaylor committed Sep 16, 2015
1 parent 79f457a commit 1cb26dc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions go/expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3472,6 +3472,15 @@ Unsafe_type_conversion_expression::do_get_backend(Translate_context* context)

Type* t = this->type_;
Type* et = this->expr_->type();

if (t->is_error_type()
|| this->expr_->is_error_expression()
|| et->is_error_type())
{
go_assert(saw_errors());
return context->backend()->error_expression();
}

if (t->array_type() != NULL)
go_assert(et->array_type() != NULL
&& t->is_slice_type() == et->is_slice_type());
Expand Down

0 comments on commit 1cb26dc

Please sign in to comment.