titzer / virgil

A fast and lightweight native programming language
1.22k stars 42 forks source link

Virgil interpreter does not return main() exit code #88

Closed srackham closed 2 years ago

srackham commented 2 years ago

Is there a reason the exit code returned by the interpreter is always zero? For example:

$ cat t.v3
def main() -> int {
        return 1;
}

$ v3c run t.v3

$ echo $?
0

$ v3c-x86-linux t.v3

$ ./t

$ echo $?
1
titzer commented 2 years ago

I hadn't noticed until now. Fixed. Thanks!

titzer commented 2 years ago

BTW a few months back I added the v3i script as a shorthand for v3c -run. I was considering even adding a special build to generate a smaller binary that includes only the interpreter, and the command would make that easier.

srackham commented 2 years ago

Thanks for the super-quick bug-fix. It works with v3i but not with v3c run:

$ v3c --version
Aeneas III-7.1536: no input files

$ cat t.v3
def main() -> int {
        return 1;
}

$ v3i t.v3

$ echo $?
1

$ v3c run t.v3

$ echo $?
0
titzer commented 2 years ago

It should be v3c -run above.

I just noticed that v3c run--in fact v3c anything_that_doesnt_end_in_dot_v3 doesn't actually do anything. That's a bug too!

srackham commented 2 years ago

Ah, my confusing virgil and v3c commands was a fortuitous mistake :-) Thanks for clearing that up.

titzer commented 2 years ago

The virgil script doesn't get much love, TBH. I had intended it to be a bit like the go command, but I end up debugging the compiler itself so much that I rarely use it.

srackham commented 2 years ago

Don't sweat the small stuff, it can be taken care of later -- just carry on with the hard stuff.