From 9504a9301be91e0ccd48cada8b3b9ddc97d03c06 Mon Sep 17 00:00:00 2001 From: allexanderbergmns Date: Mon, 24 Aug 2026 17:37:27 +0200 Subject: [PATCH] fix: make `seen` map mutable and use u64 for tagged-value shifts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The struct-literal validator declared `seen` without `mut`, causing a compile error on V. Left-shifting i64 values also produced signed-shift warnings; cast through u64 instead. 🤖 Generated with Codebuff Co-Authored-By: Codebuff --- compiler/compiler.v | 2 +- vm/vm.v | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/compiler.v b/compiler/compiler.v index c4358c9..19030cd 100644 --- a/compiler/compiler.v +++ b/compiler/compiler.v @@ -430,7 +430,7 @@ fn (mut g Gen) gen_expr(e Expr) ! { // file, where the same validation applies) if e.name.len > 0 && e.name in g.structs { decl_fields := g.structs[e.name] - seen := map[string]bool{} + mut seen := map[string]bool{} for f in e.fields { if f.name !in decl_fields { return error('unknown field "${f.name}" for struct ${e.name} (line ${e.line})') diff --git a/vm/vm.v b/vm/vm.v index 3393077..8c710d7 100644 --- a/vm/vm.v +++ b/vm/vm.v @@ -514,7 +514,7 @@ fn (mut v Vm) is_struct(x i64) bool { } fn (mut v Vm) enc_int(x i64) i64 { - return x << 2 + return u64(x) << 2 } fn (mut v Vm) dec_int(x i64) i64 { @@ -526,15 +526,15 @@ fn (mut v Vm) hand(x i64) int { } fn (mut v Vm) mkstr(idx int) i64 { - return (i64(idx) << 2) | 1 + return (u64(idx) << 2) | 1 } fn (mut v Vm) mkarr(idx int) i64 { - return (i64(idx) << 2) | 3 + return (u64(idx) << 2) | 3 } fn (mut v Vm) mkstruct_handle(idx int) i64 { - return (i64(idx) << 2) | 2 + return (u64(idx) << 2) | 2 } fn (mut v Vm) truthy(x i64) bool {