diff --git a/vlib/v/checker/tests/sync_receiver_decl.out b/vlib/v/checker/tests/sync_receiver_decl.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vlib/v/checker/tests/sync_receiver_decl.vv b/vlib/v/checker/tests/sync_receiver_decl.vv new file mode 100644 index 0000000000..29f1575bf3 --- /dev/null +++ b/vlib/v/checker/tests/sync_receiver_decl.vv @@ -0,0 +1,4 @@ +struct St {} +fn (shared b St) g() {} + +println('ok') \ No newline at end of file diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index fcbd669109..966e2a6fa2 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -623,6 +623,9 @@ fn (mut p Parser) fn_receiver(mut params []ast.Param, mut rec ReceiverParsingInf if rec.is_mut { p.next() // `mut` } + if is_shared { + p.register_auto_import('sync') + } rec_start_pos := p.tok.pos() rec.name = p.check_name() if !rec.is_mut {