From 4c422d4ff80de1f5cd055c5f793dd936593ffbca Mon Sep 17 00:00:00 2001 From: lemon Date: Tue, 6 May 2025 16:39:57 +0200 Subject: fix --- pez.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pez.c b/pez.c index 30735a2..1f50cab 100644 --- a/pez.c +++ b/pez.c @@ -529,7 +529,7 @@ delproto(PezContext *cx, Proto *pr) } } -static inline void FORCEINLINE +static inline void closeups(PezContext *cx, Val *ptr) { for (Upval *up = cx->openup, *prev = NULL, *next; up; up = next) { @@ -2299,14 +2299,14 @@ static const PezUserType file_ctype = { static bool f_ioopen(PezContext *cx, int argc) { - char buf[9]; + char buf1[9], buf2[9]; FILE *f; const char *mode = "r"; TRY(pez_checksig(cx, argc, "io#open", "string, ?string")); if (argc == 2) { - mode = pez_getstring(cx, buf, -1); + mode = pez_getstring(cx, buf1, -1); } - f = fopen(pez_getstring(cx, buf, -argc), mode); + f = fopen(pez_getstring(cx, buf2, -argc), mode); return f ? pez_pushuserobj(cx, &file_ctype, &f) : pez_pushvoid(cx); } @@ -4100,7 +4100,11 @@ stmt(Comp *cm) TRY(expectspchr(cm, '=')); TRY(box_str(cm->cx, &key, name, strlen(name))); TRY(compconst(cm, key)); - TRY(expr(cm)); // initializer + if (matchspchr(cm, '{')) { + TRY(lambdaexpr(cm, name)); // named fn + } else { + TRY(expr(cm)); // initializer + } TRY(compop(cm, Odupbck)); TRY(compop(cm, Oputglo)); } else if ((c = peekchr(cm)) == 'F' || c == 'R' || c == 'B') { -- cgit v1.2.3