diff options
| -rw-r--r-- | pez.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -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') { |