Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native: fix native new_int errors #19532

Merged
merged 9 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/tools/repeat.v
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ fn new_aints(ovals []int, extreme_mins int, extreme_maxs int) Aints {
nmaxs: extreme_maxs
}
mut sum := i64(0)
mut imin := math.max_i32
mut imax := -math.max_i32
mut imin := int(math.max_i32)
mut imax := int(-math.max_i32)
// discard the extremes:
mut vals := []int{}
for x in ovals {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/ast/types.v
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ pub const (
signed_integer_type_idxs = [char_type_idx, i8_type_idx, i16_type_idx, int_type_idx,
i64_type_idx, i32_type_idx, isize_type_idx]
unsigned_integer_type_idxs = [u8_type_idx, u16_type_idx, u32_type_idx, u64_type_idx,
usize_type_idx, i32_type_idx]
usize_type_idx]
// C will promote any type smaller than int to int in an expression
int_promoted_type_idxs = [char_type_idx, i8_type_idx, i16_type_idx, u8_type_idx, u16_type_idx]
float_type_idxs = [f32_type_idx, f64_type_idx, float_literal_type_idx]
Expand Down
4 changes: 3 additions & 1 deletion vlib/v/builder/nativebuilder/nativebuilder.v
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ pub fn build_native(mut b builder.Builder, v_files []string, out_file string) {
eprintln('Error: Only arm64 and amd64 are supported by V')
}
}
b.stats_lines, b.stats_bytes = native.gen(b.parsed_files, b.table, out_file, b.pref)
stats_lines, stats_bytes := native.gen(b.parsed_files, b.table, out_file, b.pref)
b.stats_lines = int(stats_lines)
b.stats_bytes = int(stats_bytes)
spytheman marked this conversation as resolved.
Show resolved Hide resolved
util.timing_measure('Native GEN')
}
13 changes: 10 additions & 3 deletions vlib/v/checker/tests/compare_unsigned_signed.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ vlib/v/checker/tests/compare_unsigned_signed.vv:2:14: error: unsigned integer ca
4 | }
vlib/v/checker/tests/compare_unsigned_signed.vv:6:5: error: unsigned integer cannot be compared with negative value
4 | }
5 |
5 |
6 | if -1 > u32(1) {
| ~~
7 | println('unexpected')
Expand All @@ -23,10 +23,10 @@ vlib/v/checker/tests/compare_unsigned_signed.vv:11:6: error: negative value cann
10 | _ = u8(-1) == -1 // false!
11 | _ = -1 == u16(-1) // false!
| ~~
12 |
12 |
13 | // smaller unsigned == signed, OK
vlib/v/checker/tests/compare_unsigned_signed.vv:18:12: error: `i8` cannot be compared with `u16`
16 |
16 |
17 | // smaller signed == unsigned, NG
18 | _ = i8(0) == u16(0)
| ~~
Expand All @@ -46,6 +46,13 @@ vlib/v/checker/tests/compare_unsigned_signed.vv:20:13: error: `int` cannot be co
| ~~
21 | _ = i32(0) == u64(0) // FIXME
22 | // swap order
vlib/v/checker/tests/compare_unsigned_signed.vv:21:13: error: `i32` cannot be compared with `u64`
19 | _ = i16(0) != u32(0)
20 | _ = int(0) == u64(0)
21 | _ = i32(0) == u64(0) // FIXME
| ~~
22 | // swap order
23 | _ = u16(0) == i8(0)
vlib/v/checker/tests/compare_unsigned_signed.vv:23:13: error: `u16` cannot be compared with `i8`
21 | _ = i32(0) == u64(0) // FIXME
22 | // swap order
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/checker/tests/compare_unsigned_signed.vv
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ fn main() {
// unsigned == literal
_ = u8(-1) == -1 // false!
_ = -1 == u16(-1) // false!

// smaller unsigned == signed, OK
_ = u16(-1) == int(-1)
_ = int(-1) != u8(-1)

// smaller signed == unsigned, NG
_ = i8(0) == u16(0)
_ = i16(0) != u32(0)
Expand Down
Loading
Loading