forked from AbleOS/holey-bytes
adding errors for useless type hints
This commit is contained in:
parent
d99672b751
commit
ad7fb5d0fc
|
@ -646,7 +646,7 @@ main := fn(): int {
|
||||||
i -= 1
|
i -= 1
|
||||||
}
|
}
|
||||||
// b g r
|
// b g r
|
||||||
put_pixel(.(x, y), .(@as(u8, @intcast(i)), @as(u8, @intcast(i)), @as(u8, @intcast(i)), 255))
|
put_pixel(.(x, y), .(@intcast(i), @intcast(i), @intcast(i), 255))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,7 +1030,7 @@ main := fn(): uint {
|
||||||
```hb
|
```hb
|
||||||
Color := struct {r: u8, g: u8, b: u8, a: u8}
|
Color := struct {r: u8, g: u8, b: u8, a: u8}
|
||||||
white := Color.(255, 255, 255, 255)
|
white := Color.(255, 255, 255, 255)
|
||||||
u32_to_color := fn(v: u32): Color return @as(Color, @bitcast(u32_to_u32(@bitcast(v))))
|
u32_to_color := fn(v: u32): Color return @bitcast(u32_to_u32(@bitcast(v)))
|
||||||
u32_to_u32 := fn(v: u32): u32 return v
|
u32_to_u32 := fn(v: u32): u32 return v
|
||||||
main := fn(): uint {
|
main := fn(): uint {
|
||||||
return u32_to_color(@bitcast(white)).r
|
return u32_to_color(@bitcast(white)).r
|
||||||
|
@ -1399,7 +1399,7 @@ main := fn(): uint {
|
||||||
}
|
}
|
||||||
n = 1
|
n = 1
|
||||||
loop if n >= 10 break else {
|
loop if n >= 10 break else {
|
||||||
*(@as(^[u8; 1024], @bitcast(&back_buffer)) + n) = *@as(^[u8; 1024], @bitcast(&back_buffer))
|
*(@as(^[u8; 1024], @bitcast(&back_buffer)) + n) = *@bitcast(&back_buffer)
|
||||||
n += 1
|
n += 1
|
||||||
}
|
}
|
||||||
return back_buffer[1024 * 2]
|
return back_buffer[1024 * 2]
|
||||||
|
|
|
@ -3168,10 +3168,16 @@ impl<'a> Codegen<'a> {
|
||||||
self.tys,
|
self.tys,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
Expr::Directive { name: "as", args: [ty, expr], .. } => {
|
Expr::Directive { name: "as", args: [ty, expr], pos } => {
|
||||||
let ty = self.ty(ty);
|
let ty = self.ty(ty);
|
||||||
let ctx = Ctx::default().with_ty(ty);
|
let mut val = self.raw_expr_ctx(expr, Ctx::default().with_ty(ty))?;
|
||||||
let mut val = self.raw_expr_ctx(expr, ctx)?;
|
|
||||||
|
if let Some(ity) = ctx.ty
|
||||||
|
&& ity.try_upcast(ty) == Some(ty)
|
||||||
|
&& val.ty == ity
|
||||||
|
{
|
||||||
|
self.report(pos, "the type is known at this point, remove the hint");
|
||||||
|
}
|
||||||
self.strip_var(&mut val);
|
self.strip_var(&mut val);
|
||||||
self.assert_ty(expr.pos(), &mut val, ty, "hinted expr");
|
self.assert_ty(expr.pos(), &mut val, ty, "hinted expr");
|
||||||
Some(val)
|
Some(val)
|
||||||
|
|
Loading…
Reference in a new issue