Commit b81e1cd5 by Ian Lance Taylor

compiler: check duplicate implicit indexes in slices/arrays

    
    Fixes golang/go#28186.
    
    Reviewed-on: https://go-review.googlesource.com/c/160832

From-SVN: r268554
parent 959dcbc8
047b0aa6a29d46fde99b3e5823339ac8866f797c 347628daf153baf3034b61b2abb4ec39e2ab37c8
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -14244,6 +14244,13 @@ Composite_literal_expression::lower_array(Type* type) ...@@ -14244,6 +14244,13 @@ Composite_literal_expression::lower_array(Type* type)
if (index_expr == NULL) if (index_expr == NULL)
{ {
if (std::find(indexes->begin(), indexes->end(), index)
!= indexes->end())
{
go_error_at(val->location(),
"duplicate value for index %lu", index);
return Expression::make_error(location);
}
if (!indexes->empty()) if (!indexes->empty())
indexes->push_back(index); indexes->push_back(index);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment