From 8f42f1459d43fd9debadbe5e84aa3181bf4a8cd8 Mon Sep 17 00:00:00 2001 From: CreeperFace <165158232+dy-tea@users.noreply.github.com> Date: Thu, 12 Feb 2026 06:42:55 +0000 Subject: [PATCH] parser: fix `pub:` not being detected in structs in -vls-mode (#26581) --- vlib/v/parser/struct.v | 3 ++- vlib/v/tests/vls/struct_text.vv | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index f98dea8a4..0ae449fea 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -143,7 +143,8 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl { } p.check(.lcbr) // if p.is_vls && p.tok.kind == .key_struct { // p.tok.is_key() { - if p.is_vls && p.tok.is_key() && p.tok.kind != .key_mut { + if p.is_vls && p.tok.is_key() && !(p.tok.kind in [.key_pub, .key_mut] + && p.peek_tok.kind in [.colon, .key_mut]) { // End parsing after `struct Foo {` in vls mode to avoid lots of junk errors // If next token after { is a key, the struct wasn't finished p.error('expected `}` to finish a struct definition') diff --git a/vlib/v/tests/vls/struct_text.vv b/vlib/v/tests/vls/struct_text.vv index 4c0f1bf8a..24bfdbb27 100644 --- a/vlib/v/tests/vls/struct_text.vv +++ b/vlib/v/tests/vls/struct_text.vv @@ -5,3 +5,25 @@ mut: a int b string } + +struct MyPubS { +pub: + a int + b string +} + +struct MyPubMutS { +pub mut: + a int + b string +} + +struct Complex { +mut: + mm int +pub: + pp string +pub mut: + pma int + pmb string +} -- 2.39.5