This patch improves the error message that the Go frontend issues when an unknown name in a package is used as type. It also fixes some followon errors. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
diff -r 4e6476a9ca36 go/expressions.cc --- a/go/expressions.cc Tue Sep 20 15:05:43 2011 -0700 +++ b/go/expressions.cc Tue Sep 20 15:32:18 2011 -0700 @@ -9730,7 +9730,10 @@ if (fntype == NULL) { if (ce->issue_error()) - this->report_error(_("expected function")); + { + if (!ce->fn()->type()->is_error()) + this->report_error(_("expected function")); + } this->set_is_error(); return Type::make_error_type(); } @@ -10043,7 +10046,9 @@ this->report_error(_("index must be integer")); if (this->end_ != NULL && this->end_->type()->integer_type() == NULL - && !this->end_->is_nil_expression()) + && !this->end_->type()->is_error() + && !this->end_->is_nil_expression() + && !this->end_->is_error_expression()) this->report_error(_("slice end must be integer")); Array_type* array_type = this->array_->type()->array_type(); diff -r 4e6476a9ca36 go/parse.cc --- a/go/parse.cc Tue Sep 20 15:05:43 2011 -0700 +++ b/go/parse.cc Tue Sep 20 15:32:18 2011 -0700 @@ -335,10 +335,17 @@ bool ok = true; if (named_object == NULL) { - if (package != NULL) - ok = false; + if (package == NULL) + named_object = this->gogo_->add_unknown_name(name, location); else - named_object = this->gogo_->add_unknown_name(name, location); + { + const std::string& packname(package->package_value()->name()); + error_at(location, "reference to undefined identifer %<%s.%s%>", + Gogo::message_name(packname).c_str(), + Gogo::message_name(name).c_str()); + issue_error = false; + ok = false; + } } else if (named_object->is_type()) {