`gcc -W` doesn't error for e.g. u16 == i32, only for u32 == i16. Any u16 value can fit in an i32.
parent
898167f986
commit
f291e5fdd8
|
@ -161,7 +161,7 @@ fn test_bf_from_str() {
|
||||||
output := bitfield.from_str(input)
|
output := bitfield.from_str(input)
|
||||||
mut result := 1
|
mut result := 1
|
||||||
for i in 0 .. len {
|
for i in 0 .. len {
|
||||||
if input[i] != u8(output.get_bit(i)) + 48 {
|
if input[i] != output.get_bit(i) + 48 {
|
||||||
result = 0
|
result = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,8 +288,8 @@ fn (mut ctx Context) parse_events() {
|
||||||
if !C.GetConsoleScreenBufferInfo(ctx.stdout_handle, &sb) {
|
if !C.GetConsoleScreenBufferInfo(ctx.stdout_handle, &sb) {
|
||||||
panic('could not get screenbuffer info')
|
panic('could not get screenbuffer info')
|
||||||
}
|
}
|
||||||
w := int(sb.srWindow.Right - sb.srWindow.Left + 1)
|
w := sb.srWindow.Right - sb.srWindow.Left + 1
|
||||||
h := int(sb.srWindow.Bottom - sb.srWindow.Top + 1)
|
h := sb.srWindow.Bottom - sb.srWindow.Top + 1
|
||||||
utf8 := '($ctx.window_width, $ctx.window_height) -> ($w, $h)'
|
utf8 := '($ctx.window_width, $ctx.window_height) -> ($w, $h)'
|
||||||
if w != ctx.window_width || h != ctx.window_height {
|
if w != ctx.window_width || h != ctx.window_height {
|
||||||
ctx.window_width, ctx.window_height = w, h
|
ctx.window_width, ctx.window_height = w, h
|
||||||
|
|
|
@ -639,15 +639,6 @@ pub fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
|
||||||
rt := c.table.sym(right_type).name
|
rt := c.table.sym(right_type).name
|
||||||
c.error('negative value cannot be compared with `$rt`', node.left.pos)
|
c.error('negative value cannot be compared with `$rt`', node.left.pos)
|
||||||
}
|
}
|
||||||
} else if is_left_type_signed != is_right_type_signed
|
|
||||||
&& left_type.flip_signedness() != right_type {
|
|
||||||
// prevent e.g. `u16(-1) == int(-1)` which is false in C
|
|
||||||
if (is_right_type_signed && left_type in ast.int_promoted_type_idxs)
|
|
||||||
|| (is_left_type_signed && right_type in ast.int_promoted_type_idxs) {
|
|
||||||
lt := c.table.sym(left_type).name
|
|
||||||
rt := c.table.sym(right_type).name
|
|
||||||
c.error('`$lt` cannot be compared with `$rt`', node.pos)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,24 +17,10 @@ vlib/v/checker/tests/compare_unsigned_signed.vv:10:16: error: `u8` cannot be com
|
||||||
10 | _ = u8(-1) == -1 // false!
|
10 | _ = u8(-1) == -1 // false!
|
||||||
| ~~
|
| ~~
|
||||||
11 | _ = -1 == u16(-1) // false!
|
11 | _ = -1 == u16(-1) // false!
|
||||||
12 |
|
12 | }
|
||||||
vlib/v/checker/tests/compare_unsigned_signed.vv:11:6: error: negative value cannot be compared with `u16`
|
vlib/v/checker/tests/compare_unsigned_signed.vv:11:6: error: negative value cannot be compared with `u16`
|
||||||
9 | // unsigned == literal
|
9 | // unsigned == literal
|
||||||
10 | _ = u8(-1) == -1 // false!
|
10 | _ = u8(-1) == -1 // false!
|
||||||
11 | _ = -1 == u16(-1) // false!
|
11 | _ = -1 == u16(-1) // false!
|
||||||
| ~~
|
| ~~
|
||||||
12 |
|
12 | }
|
||||||
13 | // unsigned == signed
|
|
||||||
vlib/v/checker/tests/compare_unsigned_signed.vv:14:14: error: `u16` cannot be compared with `int`
|
|
||||||
12 |
|
|
||||||
13 | // unsigned == signed
|
|
||||||
14 | _ = u16(-1) == int(-1)
|
|
||||||
| ~~
|
|
||||||
15 | _ = int(-1) != u8(-1)
|
|
||||||
16 | }
|
|
||||||
vlib/v/checker/tests/compare_unsigned_signed.vv:15:14: error: `int` cannot be compared with `u8`
|
|
||||||
13 | // unsigned == signed
|
|
||||||
14 | _ = u16(-1) == int(-1)
|
|
||||||
15 | _ = int(-1) != u8(-1)
|
|
||||||
| ~~
|
|
||||||
16 | }
|
|
||||||
|
|
|
@ -9,8 +9,4 @@ fn main() {
|
||||||
// unsigned == literal
|
// unsigned == literal
|
||||||
_ = u8(-1) == -1 // false!
|
_ = u8(-1) == -1 // false!
|
||||||
_ = -1 == u16(-1) // false!
|
_ = -1 == u16(-1) // false!
|
||||||
|
|
||||||
// unsigned == signed
|
|
||||||
_ = u16(-1) == int(-1)
|
|
||||||
_ = int(-1) != u8(-1)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -778,7 +778,7 @@ pub fn (mut bmp BitMap) draw_glyph(index u16) (int, int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if count == int(glyph.contour_ends[c]) {
|
if count == glyph.contour_ends[c] {
|
||||||
// dprintln("count == glyph.contour_ends[count]")
|
// dprintln("count == glyph.contour_ends[count]")
|
||||||
if s == 2 { // final point was off-curve. connect to start
|
if s == 2 { // final point was off-curve. connect to start
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue