mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix missing check for [export]
attr on a fn, without parameter (#17653)
This commit is contained in:
parent
aa50f4ebf7
commit
2656ce9522
@ -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()
|
||||
|
5
vlib/v/checker/tests/missing_export_attr_arg_err.out
Normal file
5
vlib/v/checker/tests/missing_export_attr_arg_err.out
Normal file
@ -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"
|
4
vlib/v/checker/tests/missing_export_attr_arg_err.vv
Normal file
4
vlib/v/checker/tests/missing_export_attr_arg_err.vv
Normal file
@ -0,0 +1,4 @@
|
||||
[export]
|
||||
fn foo() string{
|
||||
return "foo"
|
||||
}
|
Loading…
Reference in New Issue
Block a user