mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Make the return value mandatory; add ok
This commit is contained in:
1 parent
24ace1c144
commit
762b320b5e
11 files changed
+45
-50
No files matched your search
@@ -411,10 +411,8 @@ func (h *resumabilityHelper) doJump(r resumabilities, n *a.Jump, depth uint32) e
|
||||
}
|
||||
|
||||
func (h *resumabilityHelper) doRet(r resumabilities, n *a.Ret, depth uint32) error {
|
||||
if n.Value() != nil {
|
||||
if err := h.doExpr(r, n.Value()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := h.doExpr(r, n.Value()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch n.Keyword() {
|
||||
|
||||
@@ -327,7 +327,7 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
|
||||
if g.currFunk.suspendible {
|
||||
isError, isOK := false, false
|
||||
b.writes("status = ")
|
||||
if retExpr == nil {
|
||||
if retExpr.Operator() == 0 && retExpr.Ident() == t.IDOk {
|
||||
b.writes("NULL")
|
||||
isOK = true
|
||||
} else {
|
||||
@@ -364,13 +364,8 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error {
|
||||
}
|
||||
|
||||
b.writes("return ")
|
||||
if g.currFunk.astFunc.Out() == nil {
|
||||
if retExpr != nil {
|
||||
return fmt.Errorf("return expression %q incompatible with empty return type", retExpr.Str(g.tm))
|
||||
}
|
||||
} else if retExpr == nil {
|
||||
// TODO: should a bare "return" imply "return out"?
|
||||
return fmt.Errorf("empty return expression incompatible with non-empty return type")
|
||||
if g.currFunk.astFunc.Out() == nil { // TODO: Out() can be nil if the func has ? effect.
|
||||
return fmt.Errorf("TODO: allow empty return type (when not suspendible)")
|
||||
} else if err := g.writeExpr(b, retExpr, replaceCallSuspendibles, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user