mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +01:00
Type and bounds check the "x" in "return x"
This commit is contained in:
1 parent
c84732f3d3
commit
24ace1c144
3 files changed
+32
-11
No files matched your search
@@ -291,10 +291,15 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
||||
q.facts = q.facts[:0]
|
||||
|
||||
case a.KRet:
|
||||
// TODO: compare the value to the out type?
|
||||
n := n.AsRet()
|
||||
lTyp := q.astFunc.Out()
|
||||
if q.astFunc.Effect().Optional() {
|
||||
lTyp = typeExprStatus
|
||||
} else if lTyp == nil {
|
||||
return fmt.Errorf("TODO: allow returning nothing")
|
||||
}
|
||||
if v := n.Value(); v != nil {
|
||||
if _, err := q.bcheckExpr(v, 0); err != nil {
|
||||
if err := q.bcheckAssignment1(nil, lTyp, t.IDEq, v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user