mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 16:47:28 +01:00
Type check "var x T0 = y as T1".
This commit is contained in:
1 parent
497a8776c2
commit
f857d777ee
3 files changed
+14
-5
No files matched your search
+10
-1
@@ -144,7 +144,16 @@ func (q *checker) tcheckStatement(n *a.Node) error {
|
||||
if err := q.tcheckExpr(value, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
// TODO: check that value.Type is assignable to n.TypeExpr().
|
||||
lTyp := n.XType()
|
||||
rTyp := value.MType()
|
||||
if (rTyp.IsIdeal() && lTyp.IsNumType()) || lTyp.EqIgnoringRefinements(rTyp) {
|
||||
// No-op.
|
||||
} else {
|
||||
return fmt.Errorf("check: cannot assign %q of type %q to %q of type %q",
|
||||
value.String(q.tm), rTyp.String(q.tm), n.Name().String(q.tm), lTyp.String(q.tm))
|
||||
}
|
||||
} else {
|
||||
// TODO: check that the default zero value is assignable to n.XType().
|
||||
}
|
||||
|
||||
case a.KWhile:
|
||||
|
||||
Reference in new issue
Block a user