janet-lang / janet

A dynamic language and bytecode vm
https://janet-lang.org
MIT License
3.47k stars 224 forks source link

`janet -c source` with missing output files should give informative error message #1451

Closed kredati closed 2 months ago

kredati commented 4 months ago

This is my first issue; apologies if I get style or substance wrong. I absolutely adore Janet.

Desired behaviour (if not exactly expected):

$ janet -c source.janet 
> Error: expected output image path`

Actual behaviour:

$ janet -c source.janet
> error: expected integer key for array in range [0, 2), got 2
  in c-switch [boot.janet] (tailcall) on line 4066, column 18
  in cli-main [boot.janet] on line 4102, column 13

I feel like giving an internal stack trace on a user error like this is not ideal.

Alternative, possibly desired behaviour, is to use the source filename for the new image file:

$ janet -c source.janet
> Successfully builds source.jimage
bakpakin commented 3 months ago

I think this would be a good change, including the default argument