V version: commit 5da698b (post 0.1.29)
OS:
What did you do?
In a single file:
fn main() {
println("InMain: hello world!")
}
println("OutOfMain: hello world!")
What did you expect to see?
Compilation failure or
InMain: hello world!
What did you see instead?
OutOfMain: hello world!
Hmm... good catch. I don't recall anyone actually trying that before.
The reason it works now is that you don't have to have fn main() _at all_... if your entire program is
println('NoMain: Hello world!')
it works fine and prints the expected output.
However, if there _is_ a fn main(), V really should treat it as an error if there is code outside of any function.
I did it by mistake with copy-paste.
Accidental discoveries are sometimes the most important. :-)
Most helpful comment
Hmm... good catch. I don't recall anyone actually trying that before.
The reason it works now is that you don't have to have
fn main()_at all_... if your entire program isit works fine and prints the expected output.
However, if there _is_ a
fn main(), V really should treat it as an error if there is code outside of any function.