shithub: femtolisp

Download patch

ref: 6a78340ee7a0dc82389210e180a0767b5a449264
parent: 06419ca6dde8b1d14ed2dbe5c5a0e37298c5706d
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Nov 26 23:06:47 EST 2024

OP_KEYARGS: update ipd, else ip will be written in the wrong location

--- a/flisp.c
+++ b/flisp.c
@@ -1800,6 +1800,7 @@
 			ip += 4;
 			FL(stack)[ipd] = (uintptr_t)ip;
 			nargs = process_keys(v, i, n, labs(s)-(i+n), bp, nargs, s<0);
+			ipd = FL(sp)-1;
 			NEXT_OP;
 
 		OP(OP_NOP)
--- a/test/unittest.lsp
+++ b/test/unittest.lsp
@@ -227,6 +227,8 @@
 (assert (equal? (keys4 d: 10) '(8 3 7 10)))
 (assert-fail (keys4 e: 10))   ; unsupported keyword
 (assert-fail (keys4 a: 1 b:)) ; keyword with no argument
+(define (keys1 (a: 8)) (+ a 1))
+(assert (equal? (keys1 a: 11) 12))
 
 ; cvalues and arrays
 (assert (equal? (typeof "") '(array byte)))