checker: main function called error
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
|
c.returns = true
|
||||||
}
|
}
|
||||||
fn_name := call_expr.name
|
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' {
|
if fn_name == 'typeof' {
|
||||||
// TODO: impl typeof properly (probably not going to be a fn call)
|
// TODO: impl typeof properly (probably not going to be a fn call)
|
||||||
return table.string_type
|
return table.string_type
|
||||||
|
|
|
@ -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| }
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
main()
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
main()
|
||||||
|
}
|
Loading…
Reference in New Issue