diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index a7bf394ed5..d6180bcfb9 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -95,6 +95,13 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) { if node.name == 'main.main' { c.main_fn_decl_node = *node } + if node.language == .v && node.attrs.len > 0 { + if attr_export := node.attrs.find_first('export') { + if attr_export.arg == '' { + c.error('missing argument for [export] attribute', attr_export.pos) + } + } + } if node.return_type != ast.void_type { if ct_attr_idx := node.attrs.find_comptime_define() { sexpr := node.attrs[ct_attr_idx].ct_expr.str() diff --git a/vlib/v/checker/tests/missing_export_attr_arg_err.out b/vlib/v/checker/tests/missing_export_attr_arg_err.out new file mode 100644 index 0000000000..61b3af5547 --- /dev/null +++ b/vlib/v/checker/tests/missing_export_attr_arg_err.out @@ -0,0 +1,5 @@ +vlib/v/checker/tests/missing_export_attr_arg_err.vv:1:1: error: missing argument for [export] attribute + 1 | [export] + | ~~~~~~~~ + 2 | fn foo() string{ + 3 | return "foo" diff --git a/vlib/v/checker/tests/missing_export_attr_arg_err.vv b/vlib/v/checker/tests/missing_export_attr_arg_err.vv new file mode 100644 index 0000000000..d22b1ce6f3 --- /dev/null +++ b/vlib/v/checker/tests/missing_export_attr_arg_err.vv @@ -0,0 +1,4 @@ +[export] +fn foo() string{ + return "foo" +} \ No newline at end of file