Skip to content

Commit

Permalink
compiler: improve recursive type detection
Browse files Browse the repository at this point in the history
Detect recursive type definition like
"type T0 T1; type T1 T2; ...... type Tn T0".

Fixes golang/go#25320.

Change-Id: If2148b21c2857eec882309ea0cf4452209ebc6d5
Reviewed-on: https://go-review.googlesource.com/c/159837
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
benshi001 authored and ianlancetaylor committed Jan 28, 2019
1 parent f79a7dd commit 5ccb2d8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions go/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10259,6 +10259,15 @@ Find_type_use::type(Type* type)
break;

case Type::TYPE_NAMED:
if (type->named_type() == type->base()->named_type())
{
this->found_ = true;
return TRAVERSE_EXIT;
}
else
go_assert(saw_errors());
break;

case Type::TYPE_FORWARD:
go_assert(saw_errors());
break;
Expand Down

0 comments on commit 5ccb2d8

Please sign in to comment.