Message ID | mcr4o8biho3.fsf@google.com |
---|---|
State | New |
Headers | show |
diff -r 2ad66018000c go/parse.cc --- a/go/parse.cc Thu Feb 10 15:06:29 2011 -0800 +++ b/go/parse.cc Thu Feb 10 15:33:40 2011 -0800 @@ -1848,7 +1848,13 @@ *is_new = true; Variable* var = new Variable(type, init, this->gogo_->in_global_scope(), false, false, location); - return this->gogo_->add_variable(tid.name(), var); + Named_object* no = this->gogo_->add_variable(tid.name(), var); + if (!no->is_variable()) + { + // The name is already defined, so we just gave an error. + return this->gogo_->add_sink(); + } + return no; } // Create a dummy global variable to force an initializer to be run in