mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 16:47:28 +01:00
Add a nothing built-in literal
This commit is contained in:
1 parent
49627b46f2
commit
d1f1340d47
4 files changed
+12
-5
No files matched your search
@@ -308,7 +308,7 @@ func (q *checker) bcheckStatement(n *a.Node) error {
|
||||
if q.astFunc.Effect().Coroutine() {
|
||||
lTyp = typeExprStatus
|
||||
} else if lTyp == nil {
|
||||
return fmt.Errorf("TODO: allow returning nothing")
|
||||
lTyp = typeExprEmptyStruct
|
||||
}
|
||||
if _, err := q.bcheckAssignment1(nil, lTyp, t.IDEq, n.Value()); err != nil {
|
||||
return err
|
||||
|
||||
+6
-1
@@ -173,7 +173,7 @@ func (q *checker) tcheckStatement(n *a.Node) error {
|
||||
if q.astFunc.Effect().Coroutine() {
|
||||
lTyp = typeExprStatus
|
||||
} else if lTyp == nil {
|
||||
return fmt.Errorf("TODO: allow returning nothing")
|
||||
lTyp = typeExprEmptyStruct
|
||||
}
|
||||
value := n.Value()
|
||||
if err := q.tcheckExpr(value, 0); err != nil {
|
||||
@@ -391,6 +391,11 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
n.SetMType(typeExprBool)
|
||||
return nil
|
||||
|
||||
case t.IDNothing:
|
||||
n.SetConstValue(zero)
|
||||
n.SetMType(typeExprEmptyStruct)
|
||||
return nil
|
||||
|
||||
case t.IDNullptr:
|
||||
n.SetConstValue(zero)
|
||||
n.SetMType(typeExprNullptr)
|
||||
|
||||
Reference in new issue
Block a user