Allow explicit returns of built-in status codes.

This commit is contained in:
Nigel Tao committed 2017-10-06 17:34:58 +11:00
1 parent 2e883fcc23
commit 010c4db54f
7 files changed
+43 -12

No files matched your search

+9 -1
View File
@@ -122,8 +122,16 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
retExpr := (*a.Expr)(nil)
if n.Keyword() != 0 {
ret = g.statusMap[n.Message()]
if ret.name == "" {
msg := trimQuotes(n.Message().String(g.tm))
suffix := builtInStatusSuffixes[msg]
if suffix == "" {
return fmt.Errorf("no status code for %q", msg)
}
ret.name = g.PKGPREFIX + suffix
}
} else if retExpr = n.Value(); retExpr == nil {
ret.name = fmt.Sprintf("%sSTATUS_OK", g.PKGPREFIX)
ret.name = g.PKGPREFIX + "STATUS_OK"
}
if g.currFunk.suspendible {
b.writes("status = ")