Don't crash on redefined variable.
From-SVN: r170029
This commit is contained in:
parent
8629c99851
commit
d5f3d14a42
1 changed files with 7 additions and 1 deletions
|
@ -1848,7 +1848,13 @@ Parse::init_var(const Typed_identifier& tid, Type* type, Expression* init,
|
|||
*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
|
||||
|
|
Loading…
Add table
Reference in a new issue