janet-lang / spork

Various Janet utility modules - the official "Contrib" library.
MIT License
125 stars 36 forks source link

for loop was borked #123

Closed kamisori closed 1 year ago

kamisori commented 1 year ago

it printed the body doubly when it wasnt empty

kamisori commented 1 year ago

see this for an usage example:

https://github.com/kamisori/wjpu/blob/fae40b6cdc45be4312eb84f00b90c1f651f720fb/src/glfw.janet#L189

generates this with my patch:

https://github.com/kamisori/wjpu/blob/fae40b6cdc45be4312eb84f00b90c1f651f720fb/src/glfw.gen.c#L245

and this without:

https://github.com/kamisori/wjpu/blob/39e38203e2d4b1c44801e5ea2878e1ee4b6ae931/src/glfw.gen.c#LL246C19-L246C19

bakpakin commented 1 year ago

Wow that’s pretty cool. Fix is sound - the if empty logic looks a bit unneeded but that’s more of a “clean code” issue.