mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: allow parsing files without fn main()
(#5681)
This commit is contained in:
1
vlib/v/fmt/tests/no_main_expected.vv
Normal file
1
vlib/v/fmt/tests/no_main_expected.vv
Normal file
@ -0,0 +1 @@
|
|||||||
|
println('hello world')
|
1
vlib/v/fmt/tests/no_main_input.vv
Normal file
1
vlib/v/fmt/tests/no_main_input.vv
Normal file
@ -0,0 +1 @@
|
|||||||
|
println( "hello world" )
|
@ -452,6 +452,8 @@ pub fn (mut p Parser) top_stmt() ast.Stmt {
|
|||||||
file: p.file_name
|
file: p.file_name
|
||||||
return_type: table.void_type
|
return_type: table.void_type
|
||||||
}
|
}
|
||||||
|
} else if p.pref.is_fmt {
|
||||||
|
return p.stmt(false)
|
||||||
} else {
|
} else {
|
||||||
p.error('bad top level statement ' + p.tok.str())
|
p.error('bad top level statement ' + p.tok.str())
|
||||||
return ast.Stmt{}
|
return ast.Stmt{}
|
||||||
|
Reference in New Issue
Block a user