diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-04-03 11:40:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-03 11:40:01 +0100 |
| commit | e42b16b106080a376e80ead806469faaebf09b85 (patch) | |
| tree | 707590b3cbecb0eb106df3e8c706585142fb9806 | |
| parent | a1d94423808ad197cc8e16c0add50edd5b6c92f4 (diff) | |
| parent | 3a0df800664105f5944ad9e0230debe3a3207969 (diff) | |
Merge pull request #3366 from laytan/fix-vet-scope-bug
fix vet scope bug skipping some scopes
| -rw-r--r-- | core/encoding/hxa/read.odin | 2 | ||||
| -rw-r--r-- | core/encoding/json/marshal.odin | 21 | ||||
| -rw-r--r-- | core/encoding/json/unmarshal.odin | 4 | ||||
| -rw-r--r-- | core/image/netpbm/netpbm.odin | 12 | ||||
| -rw-r--r-- | core/net/addr.odin | 4 | ||||
| -rw-r--r-- | core/net/dns.odin | 1 | ||||
| -rw-r--r-- | core/net/dns_windows.odin | 7 | ||||
| -rw-r--r-- | core/net/socket.odin | 7 | ||||
| -rw-r--r-- | core/odin/printer/printer.odin | 6 | ||||
| -rw-r--r-- | core/odin/printer/visit.odin | 4 | ||||
| -rw-r--r-- | core/strconv/strconv.odin | 2 | ||||
| -rw-r--r-- | core/strings/strings.odin | 2 | ||||
| -rw-r--r-- | core/sys/info/platform_linux.odin | 4 | ||||
| -rw-r--r-- | core/text/i18n/qt_linguist.odin | 2 | ||||
| -rw-r--r-- | src/checker.cpp | 2 | ||||
| -rw-r--r-- | tests/core/image/test_core_image.odin | 4 | ||||
| -rw-r--r-- | tests/internal/test_map.odin | 12 | ||||
| -rw-r--r-- | vendor/microui/microui.odin | 18 | ||||
| -rw-r--r-- | vendor/nanovg/nanovg.odin | 6 |
19 files changed, 57 insertions, 63 deletions
diff --git a/core/encoding/hxa/read.odin b/core/encoding/hxa/read.odin index 8a8636f19..f37dc3193 100644 --- a/core/encoding/hxa/read.odin +++ b/core/encoding/hxa/read.odin @@ -177,7 +177,7 @@ read :: proc(data: []byte, filename := "<input>", print_error := false, allocato } defer file.nodes = file.nodes[:node_count] - for node_idx in 0..<header.internal_node_count { + for _ in 0..<header.internal_node_count { node := &file.nodes[node_count] type := read_value(r, Node_Type) or_return if type > max(Node_Type) { diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index 985de6880..68d087a6e 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -246,7 +246,6 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: opt_write_end(w, opt, ']') or_return case runtime.Type_Info_Enumerated_Array: - index := runtime.type_info_base(info.index).variant.(runtime.Type_Info_Enum) opt_write_start(w, opt, '[') or_return for i in 0..<info.count { opt_write_iteration(w, opt, i) or_return @@ -299,14 +298,14 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: // check for string type { - v := any{key, info.key.id} - ti := runtime.type_info_base(type_info_of(v.id)) - a := any{v.data, ti.id} + kv := any{key, info.key.id} + kti := runtime.type_info_base(type_info_of(kv.id)) + ka := any{kv.data, kti.id} name: string - #partial switch info in ti.variant { + #partial switch info in kti.variant { case runtime.Type_Info_String: - switch s in a { + switch s in ka { case string: name = s case cstring: name = string(s) } @@ -336,13 +335,13 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: // check for string type { - v := any{key, info.key.id} - ti := runtime.type_info_base(type_info_of(v.id)) - a := any{v.data, ti.id} + kv := any{key, info.key.id} + kti := runtime.type_info_base(type_info_of(kv.id)) + ka := any{kv.data, kti.id} - #partial switch info in ti.variant { + #partial switch info in kti.variant { case runtime.Type_Info_String: - switch s in a { + switch s in ka { case string: name = s case cstring: name = string(s) } diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin index 8c21098fb..edc4903a1 100644 --- a/core/encoding/json/unmarshal.odin +++ b/core/encoding/json/unmarshal.odin @@ -483,9 +483,9 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm mem.zero_slice(elem_backing) - if err := unmarshal_value(p, map_backing_value); err != nil { + if uerr := unmarshal_value(p, map_backing_value); uerr != nil { delete(key, p.allocator) - return err + return uerr } key_ptr := rawptr(&key) diff --git a/core/image/netpbm/netpbm.odin b/core/image/netpbm/netpbm.odin index 079c5b4be..ab3945ad7 100644 --- a/core/image/netpbm/netpbm.odin +++ b/core/image/netpbm/netpbm.odin @@ -199,8 +199,8 @@ save_to_buffer :: proc(img: ^Image, custom_info: Info = {}, allocator := context for x in 0 ..< img.width { i := y * img.width + x for c in 0 ..< img.channels { - i := i * img.channels + c - fmt.sbprintf(&data, "%i ", pixels[i]) + j := i * img.channels + c + fmt.sbprintf(&data, "%i ", pixels[j]) } fmt.sbprint(&data, "\n") } @@ -213,8 +213,8 @@ save_to_buffer :: proc(img: ^Image, custom_info: Info = {}, allocator := context for x in 0 ..< img.width { i := y * img.width + x for c in 0 ..< img.channels { - i := i * img.channels + c - fmt.sbprintf(&data, "%i ", pixels[i]) + j := i * img.channels + c + fmt.sbprintf(&data, "%i ", pixels[j]) } fmt.sbprint(&data, "\n") } @@ -283,7 +283,7 @@ _parse_header_pnm :: proc(data: []byte) -> (header: Header, length: int, err: Er current_field := 0 current_value := header_fields[0] - parse_loop: for d, i in data[SIG_LENGTH:] { + parse_loop: for d in data[SIG_LENGTH:] { length += 1 // handle comments @@ -728,4 +728,4 @@ _register :: proc() { _ = destroy(img) } image.register(.NetPBM, loader, destroyer) -}
\ No newline at end of file +} diff --git a/core/net/addr.odin b/core/net/addr.odin index 508399bf4..c01724d99 100644 --- a/core/net/addr.odin +++ b/core/net/addr.odin @@ -119,9 +119,9 @@ aton :: proc(address_and_maybe_port: string, family: Address_Family, allow_decim } a: [4]u8 = --- - for v, i in buf { + for v, j in buf { if v > 255 { return {}, false } - a[i] = u8(v) + a[j] = u8(v) } return IP4_Address(a), true diff --git a/core/net/dns.odin b/core/net/dns.odin index c556450c6..48cd8bf29 100644 --- a/core/net/dns.odin +++ b/core/net/dns.odin @@ -816,7 +816,6 @@ parse_response :: proc(response: []u8, filter: DNS_Record_Type = nil, allocator dq_sz :: 4 hn_sz := skip_hostname(response, cur_idx) or_return - dns_query := mem.slice_data_cast([]u16be, response[cur_idx+hn_sz:cur_idx+hn_sz+dq_sz]) cur_idx += hn_sz + dq_sz } diff --git a/core/net/dns_windows.odin b/core/net/dns_windows.odin index e54b067b6..ccec7ea4b 100644 --- a/core/net/dns_windows.odin +++ b/core/net/dns_windows.odin @@ -85,11 +85,9 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator : append(&recs, record) case .CNAME: - - hostname := strings.clone(string(r.Data.CNAME)) record := DNS_Record_CNAME{ base = base_record, - host_name = hostname, + host_name = strings.clone(string(r.Data.CNAME)), } append(&recs, record) @@ -107,10 +105,9 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator : } case .NS: - hostname := strings.clone(string(r.Data.NS)) record := DNS_Record_NS{ base = base_record, - host_name = hostname, + host_name = strings.clone(string(r.Data.NS)), } append(&recs, record) diff --git a/core/net/socket.odin b/core/net/socket.odin index 1bfa52257..5f137401e 100644 --- a/core/net/socket.odin +++ b/core/net/socket.odin @@ -161,11 +161,10 @@ recv_any :: proc(socket: Any_Socket, buf: []byte) -> ( ) { switch socktype in socket { case TCP_Socket: - bytes_read, err := recv_tcp(socktype, buf) - return bytes_read, nil, err + bytes_read, err = recv_tcp(socktype, buf) + return case UDP_Socket: - bytes_read, endpoint, err := recv_udp(socktype, buf) - return bytes_read, endpoint, err + return recv_udp(socktype, buf) case: panic("Not supported") } } diff --git a/core/odin/printer/printer.odin b/core/odin/printer/printer.odin index 63a3b543d..ce75352bd 100644 --- a/core/odin/printer/printer.odin +++ b/core/odin/printer/printer.odin @@ -643,7 +643,7 @@ align_switch_stmt :: proc(p: ^Printer, index: int) { format_tokens := make([dynamic]TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator)
//find all the switch cases that are one lined
- for line, line_index in p.lines[brace_line + 1:] {
+ for line in p.lines[brace_line + 1:] {
case_found := false
colon_found := false
@@ -716,7 +716,7 @@ align_enum :: proc(p: ^Printer, index: int) { format_tokens := make([dynamic]TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator)
- for line, line_index in p.lines[brace_line + 1:] {
+ for line in p.lines[brace_line + 1:] {
length := 0
for format_token, i in line.format_tokens {
@@ -880,7 +880,7 @@ align_comments :: proc(p: ^Printer) { length := 0
- for format_token, i in line.format_tokens {
+ for format_token in line.format_tokens {
if format_token.kind == .Comment {
current_info.length = max(current_info.length, length)
current_info.end = line_index
diff --git a/core/odin/printer/visit.odin b/core/odin/printer/visit.odin index 1aefcf967..7dd208a49 100644 --- a/core/odin/printer/visit.odin +++ b/core/odin/printer/visit.odin @@ -1462,9 +1462,9 @@ visit_binary_expr :: proc(p: ^Printer, binary: ^ast.Binary_Expr) { }
either_implicit_selector := false
- if _, ok := binary.left.derived.(^ast.Implicit_Selector_Expr); ok {
+ if _, lok := binary.left.derived.(^ast.Implicit_Selector_Expr); lok {
either_implicit_selector = true
- } else if _, ok := binary.right.derived.(^ast.Implicit_Selector_Expr); ok {
+ } else if _, rok := binary.right.derived.(^ast.Implicit_Selector_Expr); rok {
either_implicit_selector = true
}
diff --git a/core/strconv/strconv.odin b/core/strconv/strconv.odin index eae9f9504..f23e619dc 100644 --- a/core/strconv/strconv.odin +++ b/core/strconv/strconv.odin @@ -878,7 +878,7 @@ parse_f64_prefix :: proc(str: string) -> (value: f64, nr: int, ok: bool) { s = s[1:] fallthrough case 'i', 'I': - n := common_prefix_len_ignore_case(s, "infinity") + n = common_prefix_len_ignore_case(s, "infinity") if 3 < n && n < 8 { // "inf" or "infinity" n = 3 } diff --git a/core/strings/strings.odin b/core/strings/strings.odin index 5cee25a66..13c53f48e 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -809,7 +809,7 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato n = l } - res := make([]string, n, allocator, loc) or_return + res = make([]string, n, allocator, loc) or_return for i := 0; i < n-1; i += 1 { _, w := utf8.decode_rune_in_string(s) res[i] = s[:w] diff --git a/core/sys/info/platform_linux.odin b/core/sys/info/platform_linux.odin index 93770a460..89b1204a7 100644 --- a/core/sys/info/platform_linux.odin +++ b/core/sys/info/platform_linux.odin @@ -18,8 +18,8 @@ init_os_version :: proc () { fd, errno := linux.open("/etc/os-release", {.RDONLY}, {}) assert(errno == .NONE, "Failed to read /etc/os-release") defer { - errno := linux.close(fd) - assert(errno == .NONE, "Failed to close the file descriptor") + cerrno := linux.close(fd) + assert(cerrno == .NONE, "Failed to close the file descriptor") } os_release_buf: [2048]u8 n, read_errno := linux.read(fd, os_release_buf[:]) diff --git a/core/text/i18n/qt_linguist.odin b/core/text/i18n/qt_linguist.odin index fa05a6dc1..0e75df873 100644 --- a/core/text/i18n/qt_linguist.odin +++ b/core/text/i18n/qt_linguist.odin @@ -128,7 +128,7 @@ parse_qt_linguist_from_bytes :: proc(data: []byte, options := DEFAULT_PARSE_OPTI num_plurals: int for { - numerus_id := xml.find_child_by_ident(ts, translation_id, "numerusform", num_plurals) or_break + xml.find_child_by_ident(ts, translation_id, "numerusform", num_plurals) or_break num_plurals += 1 } diff --git a/src/checker.cpp b/src/checker.cpp index 82f0a09be..244e7efbd 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -224,7 +224,7 @@ gb_internal Scope *create_scope(CheckerInfo *info, Scope *parent) { if (parent != nullptr && parent != builtin_pkg->scope) { Scope *prev_head_child = parent->head_child.exchange(s, std::memory_order_acq_rel); if (prev_head_child) { - prev_head_child->next.store(s, std::memory_order_release); + s->next.store(prev_head_child, std::memory_order_release); } } diff --git a/tests/core/image/test_core_image.odin b/tests/core/image/test_core_image.odin index 54b3608b7..ae92ca617 100644 --- a/tests/core/image/test_core_image.odin +++ b/tests/core/image/test_core_image.odin @@ -1580,7 +1580,7 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) { { // Roundtrip through PBM to test the PBM encoders and decoders - prefer ASCII - pbm_info, pbm_format_selected := pbm.autoselect_pbm_format_from_image(img, false) + pbm_info, _ := pbm.autoselect_pbm_format_from_image(img, false) // We already tested the binary formats above. if pbm_info.header.format in pbm.ASCII { @@ -1912,4 +1912,4 @@ run_png_suite :: proc(t: ^testing.T, suite: []PNG_Test) -> (subtotal: int) { } return -}
\ No newline at end of file +} diff --git a/tests/internal/test_map.odin b/tests/internal/test_map.odin index 2c808d85e..7d1dbf470 100644 --- a/tests/internal/test_map.odin +++ b/tests/internal/test_map.odin @@ -32,7 +32,7 @@ map_insert_random_key_value :: proc(t: ^testing.T) { } key_count := 0 - for k in m { + for _ in m { key_count += 1 } @@ -82,7 +82,7 @@ map_update_random_key_value :: proc(t: ^testing.T) { } key_count := 0 - for k in m { + for _ in m { key_count += 1 } @@ -144,7 +144,7 @@ map_delete_random_key_value :: proc(t: ^testing.T) { } key_count := 0 - for k in m { + for _ in m { key_count += 1 } @@ -220,7 +220,7 @@ set_insert_random_key_value :: proc(t: ^testing.T) { } key_count := 0 - for k in m { + for _ in m { key_count += 1 } @@ -268,7 +268,7 @@ set_delete_random_key_value :: proc(t: ^testing.T) { } key_count := 0 - for k in m { + for _ in m { key_count += 1 } @@ -379,4 +379,4 @@ when ODIN_TEST { fmt.printf("[%v] ", loc) fmt.printf("log: %v\n", v) } -}
\ No newline at end of file +} diff --git a/vendor/microui/microui.odin b/vendor/microui/microui.odin index 1ddad2121..495289ede 100644 --- a/vendor/microui/microui.odin +++ b/vendor/microui/microui.odin @@ -1316,10 +1316,10 @@ begin_window :: proc(ctx: ^Context, title: string, rect: Rect, opt := Options{}) /* do title text */ if .NO_TITLE not_in opt { - id := get_id(ctx, "!title") - update_control(ctx, id, tr, opt) + tid := get_id(ctx, "!title") + update_control(ctx, tid, tr, opt) draw_control_text(ctx, title, tr, .TITLE_TEXT, opt) - if id == ctx.focus_id && ctx.mouse_down_bits == {.LEFT} { + if tid == ctx.focus_id && ctx.mouse_down_bits == {.LEFT} { cnt.rect.x += ctx.mouse_delta.x cnt.rect.y += ctx.mouse_delta.y } @@ -1329,12 +1329,12 @@ begin_window :: proc(ctx: ^Context, title: string, rect: Rect, opt := Options{}) /* do `close` button */ if .NO_CLOSE not_in opt { - id := get_id(ctx, "!close") + cid := get_id(ctx, "!close") r := Rect{tr.x + tr.w - tr.h, tr.y, tr.h, tr.h} tr.w -= r.w draw_icon(ctx, .CLOSE, r, ctx.style.colors[.TITLE_TEXT]) - update_control(ctx, id, r, opt) - if .LEFT in ctx.mouse_released_bits && id == ctx.hover_id { + update_control(ctx, cid, r, opt) + if .LEFT in ctx.mouse_released_bits && cid == ctx.hover_id { cnt.open = false } } @@ -1343,11 +1343,11 @@ begin_window :: proc(ctx: ^Context, title: string, rect: Rect, opt := Options{}) /* do `resize` handle */ if .NO_RESIZE not_in opt { sz := ctx.style.footer_height - id := get_id(ctx, "!resize") + rid := get_id(ctx, "!resize") r := Rect{rect.x + rect.w - sz, rect.y + rect.h - sz, sz, sz} draw_icon(ctx, .RESIZE, r, ctx.style.colors[.TEXT]) - update_control(ctx, id, r, opt) - if id == ctx.focus_id && .LEFT in ctx.mouse_down_bits { + update_control(ctx, rid, r, opt) + if rid == ctx.focus_id && .LEFT in ctx.mouse_down_bits { cnt.rect.w = max(96, cnt.rect.w + ctx.mouse_delta.x) cnt.rect.h = max(64, cnt.rect.h + ctx.mouse_delta.y) } diff --git a/vendor/nanovg/nanovg.odin b/vendor/nanovg/nanovg.odin index 74fc70692..15611cfef 100644 --- a/vendor/nanovg/nanovg.odin +++ b/vendor/nanovg/nanovg.odin @@ -2009,7 +2009,7 @@ __expandStroke :: proc( } } - for j in start..<end { + for _ in start..<end { // TODO check this // if ((p1.flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) { if (.BEVEL in p1.flags) || (.INNER_BEVEL in p1.flags) { @@ -2172,7 +2172,7 @@ __expandFill :: proc( __vset(&dst, verts[dst_index + 0].x, verts[dst_index + 0].y, lu, 1) __vset(&dst, verts[dst_index + 1].x, verts[dst_index + 1].y, ru, 1) - dst_diff := dst_start_length - len(dst) + dst_diff = dst_start_length - len(dst) path.stroke = verts[dst_index:dst_index + dst_diff] // advance @@ -3361,7 +3361,7 @@ TextBoxBounds :: proc( rows_mod := rows[:] y := y - for nrows, input_last in TextBreakLines(ctx, &input, breakRowWidth, &rows_mod) { + for nrows in TextBreakLines(ctx, &input, breakRowWidth, &rows_mod) { for row in rows[:nrows] { rminx, rmaxx, dx: f32 |