janet-lang / janet

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

Disasm/asm doesn't round-trip for function with unused argument #1424

Closed thegeez closed 3 months ago

thegeez commented 4 months ago

This doesn't round trip:

(asm (disasm 
    (fn [] 
       (def foo (fn [one two] one)) 
       (foo 100 200))))

This trips up this line in the bytecode verifier about slotcounts: https://github.com/janet-lang/janet/blob/6032a6d65874514f88690aaf35e97f53a0ab6176/src/core/bytecode.c#L409

This example does work when foo returns two instead of one:

(asm (disasm 
    (fn [] 
       (def foo (fn [one two] two)) 
       (foo 100 200))))
bakpakin commented 3 months ago

Fixed in 9e6abbf4d40b3ebe121147b9e51a68f6746e3848