mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 00:47:56 +01:00
Allow explicit returns of built-in status codes.
This commit is contained in:
1 parent
2e883fcc23
commit
010c4db54f
7 files changed
+43
-12
No files matched your search
+11
-4
@@ -120,10 +120,17 @@ func (q *checker) tcheckStatement(n *a.Node) error {
|
||||
case a.KReturn:
|
||||
n := n.Return()
|
||||
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 {
|
||||
sk := t.ID(0)
|
||||
if s, ok := q.c.statuses[n.Message()]; ok {
|
||||
sk = s.Status.Keyword()
|
||||
} else {
|
||||
msg := trimQuotes(n.Message().String(q.tm))
|
||||
sk, ok = builtInStatuses[msg]
|
||||
if !ok {
|
||||
return fmt.Errorf("check: no error or status with message %q", msg)
|
||||
}
|
||||
}
|
||||
if nk != sk {
|
||||
return fmt.Errorf("check: return statement says %q but declaration says %q",
|
||||
nk.String(q.tm), sk.String(q.tm))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user