mirror of
https://github.com/vlang/v.git
synced 2025-09-23 04:18:48 -04:00
checker: main function called error
This commit is contained in:
parent
9edbcb823c
commit
b20777df59
@ -677,6 +677,9 @@ pub fn (mut c Checker) call_fn(call_expr mut ast.CallExpr) table.Type {
|
||||
c.returns = true
|
||||
}
|
||||
fn_name := call_expr.name
|
||||
if fn_name == 'main' {
|
||||
c.error('the `main` function cannot be called in the program', call_expr.pos)
|
||||
}
|
||||
if fn_name == 'typeof' {
|
||||
// TODO: impl typeof properly (probably not going to be a fn call)
|
||||
return table.string_type
|
||||
|
5
vlib/v/checker/tests/main_called_err.out
Normal file
5
vlib/v/checker/tests/main_called_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/main_called_err.v:2:2: error: the `main` function cannot be called in the program
|
||||
1| fn main() {
|
||||
2| main()
|
||||
~~~~~~
|
||||
3| }
|
3
vlib/v/checker/tests/main_called_err.v
Normal file
3
vlib/v/checker/tests/main_called_err.v
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
main()
|
||||
}
|
3
vlib/v/checker/tests/main_called_err.vv
Normal file
3
vlib/v/checker/tests/main_called_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
main()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user