Type check "var x T0 = y as T1".

This commit is contained in:
Nigel Tao committed 2017-06-22 15:31:55 +10:00
1 parent 497a8776c2
commit f857d777ee
3 files changed
+14 -5

No files matched your search

+2 -2
View File
@@ -478,7 +478,7 @@ puffs_gif_status puffs_gif_decoder_decode_extension(puffs_gif_decoder* self,
return status;
}
uint8_t t_1 = a_src.buf->ptr[a_src.buf->ri++];
v_block_size = ((uint32_t)(t_1));
v_block_size = t_1;
if (v_block_size == 0) {
goto label_0_break;
}
@@ -546,7 +546,7 @@ puffs_gif_status puffs_gif_decoder_decode_id(puffs_gif_decoder* self,
return status;
}
uint8_t t_2 = a_src.buf->ptr[a_src.buf->ri++];
v_block_size = ((uint32_t)(t_2));
v_block_size = t_2;
if (v_block_size == 0) {
goto label_0_break;
}
+10 -1
View File
@@ -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:
+2 -2
View File
@@ -105,7 +105,7 @@ pri func decoder.decode_extension?(src reader1)() {
// Skip the data blocks.
while true {
var block_size u8 = in.src.read_u8?() as u32
var block_size u8 = in.src.read_u8?()
if block_size == 0 {
break
}
@@ -145,7 +145,7 @@ pri func decoder.decode_id?(src reader1)() {
// TODO: pass the data blocks' payload to this.lzw.
while true {
var block_size u8 = in.src.read_u8?() as u32
var block_size u8 = in.src.read_u8?()
if block_size == 0 {
break
}