janet-lang / janet

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

Warning/error on seq with no body #1470

Open sarna opened 1 week ago

sarna commented 1 week ago

It'd be nice if Janet warned you (threw an error, printed a warning, ...) when you don't provide the body for seq, for example:

(seq [i :range [0 5]])

Right now it will happily return @[nil nil nil nil nil]. I can't think of a reason why a user wanted to write it this way.

The same thing happens with loop, not sure about other looping constructs.

sogaiu commented 1 week ago

I guess if one wanted 5 nils, it would be clearer to express it like:

(seq [i :range [0 5]] nil)