From 2df260acbb94b38d0fc09421d509c4696e476e9c Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Tue, 20 Apr 2021 20:37:00 +0200 Subject: [PATCH] parser: fix last_line of no body C struct (#9809) --- vlib/v/fmt/tests/structs_expected.vv | 2 ++ vlib/v/fmt/tests/structs_input.vv | 2 ++ vlib/v/parser/struct.v | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/vlib/v/fmt/tests/structs_expected.vv b/vlib/v/fmt/tests/structs_expected.vv index 67e28523a4..ee5b9c36d9 100644 --- a/vlib/v/fmt/tests/structs_expected.vv +++ b/vlib/v/fmt/tests/structs_expected.vv @@ -58,3 +58,5 @@ pub: 14 */ } + +struct C.Foo {} diff --git a/vlib/v/fmt/tests/structs_input.vv b/vlib/v/fmt/tests/structs_input.vv index 39c4288708..dd74dfc4f4 100644 --- a/vlib/v/fmt/tests/structs_input.vv +++ b/vlib/v/fmt/tests/structs_input.vv @@ -61,3 +61,5 @@ somefield4 int 14 */ } + +struct C.Foo diff --git a/vlib/v/parser/struct.v b/vlib/v/parser/struct.v index e9b6bba310..ea670fe061 100644 --- a/vlib/v/parser/struct.v +++ b/vlib/v/parser/struct.v @@ -96,7 +96,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl { mut is_field_mut := false mut is_field_pub := false mut is_field_global := false - mut last_line := -1 + mut last_line := p.prev_tok.position().line_nr + 1 mut end_comments := []ast.Comment{} if !no_body { p.check(.lcbr)