Merge pull request #3366 from laytan/fix-vet-scope-bug

fix vet scope bug skipping some scopes
This commit is contained in:
gingerBill
2024-04-03 11:40:01 +01:00
committed by GitHub
19 changed files with 57 additions and 63 deletions

View File

@@ -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) {

View File

@@ -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)
}

View File

@@ -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)

View File

@@ -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)
}
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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)

View File

@@ -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")
}
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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]

View File

@@ -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[:])

View File

@@ -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
}

View File

@@ -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);
}
}

View File

@@ -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
}
}

View File

@@ -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)
}
}
}

View File

@@ -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)
}

View File

@@ -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