Add user-defined error and status codes.

This commit is contained in:
Nigel Tao committed 2017-06-09 12:26:00 +10:00
1 parent 90e49caf51
commit 3863427127
10 files changed
+282 -42

No files matched your search

+9 -1
View File
@@ -106,7 +106,15 @@ func (q *checker) tcheckStatement(n *a.Node) error {
case a.KReturn:
n := n.Return()
if value := n.Value(); value != nil {
if nk := n.Keyword(); nk != 0 {
if s, ok := q.c.statuses[n.Message()]; !ok {
return fmt.Errorf("check: no error or status with message %q",
trimQuotes(n.Message().String(q.tm)))
} else if sk := s.Status.Keyword(); nk != sk {
return fmt.Errorf("check: return statement says %q but declaration says %q",
nk.String(q.tm), sk.String(q.tm))
}
} else if value := n.Value(); value != nil {
if err := q.tcheckExpr(value, 0); err != nil {
return err
}