Browse Source

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

fix vet scope bug skipping some scopes
gingerBill 1 year ago
parent
commit
e42b16b106

+ 1 - 1
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]
 	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]
 		node := &file.nodes[node_count]
 		type := read_value(r, Node_Type) or_return
 		type := read_value(r, Node_Type) or_return
 		if type > max(Node_Type) {
 		if type > max(Node_Type) {

+ 10 - 11
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
 		opt_write_end(w, opt, ']') or_return
 		
 		
 	case runtime.Type_Info_Enumerated_Array:
 	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
 		opt_write_start(w, opt, '[') or_return
 		for i in 0..<info.count {
 		for i in 0..<info.count {
 			opt_write_iteration(w, opt, i) or_return
 			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
 					// 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
 						name: string
 
 
-						#partial switch info in ti.variant {
+						#partial switch info in kti.variant {
 						case runtime.Type_Info_String:
 						case runtime.Type_Info_String:
-							switch s in a {
+							switch s in ka {
 							case string: name = s
 							case string: name = s
 							case cstring: name = string(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
 					// 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:
 						case runtime.Type_Info_String:
-							switch s in a {
+							switch s in ka {
 							case string: name = s
 							case string: name = s
 							case cstring: name = string(s)
 							case cstring: name = string(s)
 							}
 							}

+ 2 - 2
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)
 			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)
 				delete(key, p.allocator)
-				return err
+				return uerr
 			}
 			}
 
 
 			key_ptr := rawptr(&key)
 			key_ptr := rawptr(&key)

+ 6 - 6
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 {
 				for x in 0 ..< img.width {
 					i := y * img.width + x
 					i := y * img.width + x
 					for c in 0 ..< img.channels {
 					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")
 					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 {
 				for x in 0 ..< img.width {
 					i := y * img.width + x
 					i := y * img.width + x
 					for c in 0 ..< img.channels {
 					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")
 					fmt.sbprint(&data, "\n")
 				}
 				}
@@ -283,7 +283,7 @@ _parse_header_pnm :: proc(data: []byte) -> (header: Header, length: int, err: Er
 	current_field := 0
 	current_field := 0
 	current_value := header_fields[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
 		length += 1
 
 
 		// handle comments
 		// handle comments
@@ -728,4 +728,4 @@ _register :: proc() {
 		_ = destroy(img)
 		_ = destroy(img)
 	}
 	}
 	image.register(.NetPBM, loader, destroyer)
 	image.register(.NetPBM, loader, destroyer)
-}
+}

+ 2 - 2
core/net/addr.odin

@@ -119,9 +119,9 @@ aton :: proc(address_and_maybe_port: string, family: Address_Family, allow_decim
 		}
 		}
 
 
 		a: [4]u8 = ---
 		a: [4]u8 = ---
-		for v, i in buf {
+		for v, j in buf {
 			if v > 255 { return {}, false }
 			if v > 255 { return {}, false }
-			a[i] = u8(v)
+			a[j] = u8(v)
 		}
 		}
 		return IP4_Address(a), true
 		return IP4_Address(a), true
 
 

+ 0 - 1
core/net/dns.odin

@@ -816,7 +816,6 @@ parse_response :: proc(response: []u8, filter: DNS_Record_Type = nil, allocator
 
 
 		dq_sz :: 4
 		dq_sz :: 4
 		hn_sz := skip_hostname(response, cur_idx) or_return
 		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
 		cur_idx += hn_sz + dq_sz
 	}
 	}

+ 2 - 5
core/net/dns_windows.odin

@@ -85,11 +85,9 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator :
 			append(&recs, record)
 			append(&recs, record)
 
 
 		case .CNAME:
 		case .CNAME:
-
-			hostname := strings.clone(string(r.Data.CNAME))
 			record := DNS_Record_CNAME{
 			record := DNS_Record_CNAME{
 				base      = base_record,
 				base      = base_record,
-				host_name = hostname,
+				host_name = strings.clone(string(r.Data.CNAME)),
 			}
 			}
 			append(&recs, record)
 			append(&recs, record)
 
 
@@ -107,10 +105,9 @@ _get_dns_records_os :: proc(hostname: string, type: DNS_Record_Type, allocator :
 			}
 			}
 
 
 		case .NS:
 		case .NS:
-			hostname := strings.clone(string(r.Data.NS))
 			record := DNS_Record_NS{
 			record := DNS_Record_NS{
 				base      = base_record,
 				base      = base_record,
-				host_name = hostname,
+				host_name = strings.clone(string(r.Data.NS)),
 			}
 			}
 			append(&recs, record)
 			append(&recs, record)
 
 

+ 3 - 4
core/net/socket.odin

@@ -161,11 +161,10 @@ recv_any :: proc(socket: Any_Socket, buf: []byte) -> (
 ) {
 ) {
 	switch socktype in socket {
 	switch socktype in socket {
 	case TCP_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:
 	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")
 	case: panic("Not supported")
 	}
 	}
 }
 }

+ 3 - 3
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)
 	format_tokens := make([dynamic]TokenAndLength, 0, brace_token.parameter_count, context.temp_allocator)
 
 
 	//find all the switch cases that are one lined
 	//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
 		case_found  := false
 		colon_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)
 	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
 		length := 0
 
 
 		for format_token, i in line.format_tokens {
 		for format_token, i in line.format_tokens {
@@ -880,7 +880,7 @@ align_comments :: proc(p: ^Printer) {
 
 
 			length := 0
 			length := 0
 
 
-			for format_token, i in line.format_tokens {
+			for format_token in line.format_tokens {
 				if format_token.kind == .Comment {
 				if format_token.kind == .Comment {
 					current_info.length = max(current_info.length, length)
 					current_info.length = max(current_info.length, length)
 					current_info.end = line_index
 					current_info.end = line_index

+ 2 - 2
core/odin/printer/visit.odin

@@ -1462,9 +1462,9 @@ visit_binary_expr :: proc(p: ^Printer, binary: ^ast.Binary_Expr) {
 	}
 	}
 
 
 	either_implicit_selector := false
 	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
 		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
 		either_implicit_selector = true
 	}
 	}
 
 

+ 1 - 1
core/strconv/strconv.odin

@@ -878,7 +878,7 @@ parse_f64_prefix :: proc(str: string) -> (value: f64, nr: int, ok: bool) {
 				s = s[1:]
 				s = s[1:]
 				fallthrough
 				fallthrough
 			case 'i', 'I':
 			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"
 				if 3 < n && n < 8 { // "inf" or "infinity"
 					n = 3
 					n = 3
 				}
 				}

+ 1 - 1
core/strings/strings.odin

@@ -809,7 +809,7 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato
 			n = l
 			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 {
 		for i := 0; i < n-1; i += 1 {
 			_, w := utf8.decode_rune_in_string(s)
 			_, w := utf8.decode_rune_in_string(s)
 			res[i] = s[:w]
 			res[i] = s[:w]

+ 2 - 2
core/sys/info/platform_linux.odin

@@ -18,8 +18,8 @@ init_os_version :: proc () {
 	fd, errno := linux.open("/etc/os-release", {.RDONLY}, {})
 	fd, errno := linux.open("/etc/os-release", {.RDONLY}, {})
 	assert(errno == .NONE, "Failed to read /etc/os-release")
 	assert(errno == .NONE, "Failed to read /etc/os-release")
 	defer {
 	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
 	os_release_buf: [2048]u8
 	n, read_errno := linux.read(fd, os_release_buf[:])
 	n, read_errno := linux.read(fd, os_release_buf[:])

+ 1 - 1
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
 				num_plurals: int
 				for {
 				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
 					num_plurals += 1
 				}
 				}
 
 

+ 1 - 1
src/checker.cpp

@@ -224,7 +224,7 @@ gb_internal Scope *create_scope(CheckerInfo *info, Scope *parent) {
 	if (parent != nullptr && parent != builtin_pkg->scope) {
 	if (parent != nullptr && parent != builtin_pkg->scope) {
 		Scope *prev_head_child = parent->head_child.exchange(s, std::memory_order_acq_rel);
 		Scope *prev_head_child = parent->head_child.exchange(s, std::memory_order_acq_rel);
 		if (prev_head_child) {
 		if (prev_head_child) {
-			prev_head_child->next.store(s, std::memory_order_release);
+			s->next.store(prev_head_child, std::memory_order_release);
 		}
 		}
 	}
 	}
 
 

+ 2 - 2
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
 						// 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.
 						// We already tested the binary formats above.
 						if pbm_info.header.format in pbm.ASCII {
 						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
 	return
-}
+}

+ 6 - 6
tests/internal/test_map.odin

@@ -32,7 +32,7 @@ map_insert_random_key_value :: proc(t: ^testing.T) {
 		}
 		}
 
 
 		key_count := 0
 		key_count := 0
-		for k in m {
+		for _ in m {
 			key_count += 1
 			key_count += 1
 		}
 		}
 
 
@@ -82,7 +82,7 @@ map_update_random_key_value :: proc(t: ^testing.T) {
 		}
 		}
 
 
 		key_count := 0
 		key_count := 0
-		for k in m {
+		for _ in m {
 			key_count += 1
 			key_count += 1
 		}
 		}
 
 
@@ -144,7 +144,7 @@ map_delete_random_key_value :: proc(t: ^testing.T) {
 		}
 		}
 
 
 		key_count := 0
 		key_count := 0
-		for k in m {
+		for _ in m {
 			key_count += 1
 			key_count += 1
 		}
 		}
 
 
@@ -220,7 +220,7 @@ set_insert_random_key_value :: proc(t: ^testing.T) {
 		}
 		}
 
 
 		key_count := 0
 		key_count := 0
-		for k in m {
+		for _ in m {
 			key_count += 1
 			key_count += 1
 		}
 		}
 
 
@@ -268,7 +268,7 @@ set_delete_random_key_value :: proc(t: ^testing.T) {
 		}
 		}
 
 
 		key_count := 0
 		key_count := 0
-		for k in m {
+		for _ in m {
 			key_count += 1
 			key_count += 1
 		}
 		}
 
 
@@ -379,4 +379,4 @@ when ODIN_TEST {
 		fmt.printf("[%v] ", loc)
 		fmt.printf("[%v] ", loc)
 		fmt.printf("log: %v\n", v)
 		fmt.printf("log: %v\n", v)
 	}
 	}
-}
+}

+ 9 - 9
vendor/microui/microui.odin

@@ -1316,10 +1316,10 @@ begin_window :: proc(ctx: ^Context, title: string, rect: Rect, opt := Options{})
 
 
 		/* do title text */
 		/* do title text */
 		if .NO_TITLE not_in opt {
 		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)
 			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.x += ctx.mouse_delta.x
 				cnt.rect.y += ctx.mouse_delta.y
 				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 */
 		/* do `close` button */
 		if .NO_CLOSE not_in opt {
 		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}
 			r := Rect{tr.x + tr.w - tr.h, tr.y, tr.h, tr.h}
 			tr.w -= r.w
 			tr.w -= r.w
 			draw_icon(ctx, .CLOSE, r, ctx.style.colors[.TITLE_TEXT])
 			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
 				cnt.open = false
 			}
 			}
 		}
 		}
@@ -1343,11 +1343,11 @@ begin_window :: proc(ctx: ^Context, title: string, rect: Rect, opt := Options{})
 	/* do `resize` handle */
 	/* do `resize` handle */
 	if .NO_RESIZE not_in opt {
 	if .NO_RESIZE not_in opt {
 		sz := ctx.style.footer_height
 		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}
 		r := Rect{rect.x + rect.w - sz, rect.y + rect.h - sz, sz, sz}
 		draw_icon(ctx, .RESIZE, r, ctx.style.colors[.TEXT])
 		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.w = max(96, cnt.rect.w + ctx.mouse_delta.x)
 			cnt.rect.h = max(64, cnt.rect.h + ctx.mouse_delta.y)
 			cnt.rect.h = max(64, cnt.rect.h + ctx.mouse_delta.y)
 		}
 		}

+ 3 - 3
vendor/nanovg/nanovg.odin

@@ -2009,7 +2009,7 @@ __expandStroke :: proc(
 			}
 			}
 		}
 		}
 
 
-		for j in start..<end {
+		for _ in start..<end {
 			// TODO check this
 			// TODO check this
 			// if ((p1.flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) {
 			// if ((p1.flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) {
 			if (.BEVEL in p1.flags) || (.INNER_BEVEL in p1.flags) {
 			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 + 0].x, verts[dst_index + 0].y, lu, 1)
 			__vset(&dst, verts[dst_index + 1].x, verts[dst_index + 1].y, ru, 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]
 			path.stroke = verts[dst_index:dst_index + dst_diff]
 
 
 			// advance
 			// advance
@@ -3361,7 +3361,7 @@ TextBoxBounds :: proc(
 	rows_mod := rows[:]
 	rows_mod := rows[:]
 	y := y
 	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] {
 		for row in rows[:nrows] {
 			rminx, rmaxx, dx: f32
 			rminx, rmaxx, dx: f32