From 38100faecf50605574179cb81c8bf7cb5a8b55d7 Mon Sep 17 00:00:00 2001 From: Lukas Neubert Date: Wed, 21 Jul 2021 10:48:12 +0200 Subject: [PATCH] fmt, parser: fix pos.last_line for assembly blocks (#10877) --- vlib/v/fmt/tests/newlines_keep.vv | 8 ++++++++ vlib/v/parser/parser.v | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/vlib/v/fmt/tests/newlines_keep.vv b/vlib/v/fmt/tests/newlines_keep.vv index 01665c0d50..7d70d56af7 100644 --- a/vlib/v/fmt/tests/newlines_keep.vv +++ b/vlib/v/fmt/tests/newlines_keep.vv @@ -22,3 +22,11 @@ fn y_with_attr() { [typedef] struct FooWithAttr { } + +fn between_assembly_blocks() { + asm amd64 { + } + + asm i386 { + } +} diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 4928f25a17..2e6cc7d894 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1067,7 +1067,7 @@ fn (mut p Parser) asm_stmt(is_top_level bool) ast.AsmStmt { output: output input: input clobbered: clobbered - pos: pos.extend(p.tok.position()) + pos: pos.extend(p.prev_tok.position()) is_basic: is_top_level || output.len + input.len + clobbered.len == 0 scope: scope global_labels: global_labels