Closed klange closed 2 years ago
I think this ought to do it...
diff --git a/src/compiler.c b/src/compiler.c
index 3737fc4..95985e9 100644
--- a/src/compiler.c
+++ b/src/compiler.c
@@ -2493,7 +2493,21 @@ static void string(int exprType) {
}
}
c += 2;
+ } else if (isFormat && *c == '}') {
+ if (c[1] != '}') {
+ error("single '}' not allowed in f-string");
+ FREE_ARRAY(char,stringBytes,stringCapacity);
+ return;
+ }
+ PUSH_CHAR('}');
+ c += 2;
+ continue;
} else if (isFormat && *c == '{') {
+ if (c[1] == '{') {
+ PUSH_CHAR('{');
+ c += 2;
+ continue;
+ }
if (!atLeastOne || stringLength) { /* Make sure there's a string for coersion reasons */
emitConstant(OBJECT_VAL(krk_copyString(stringBytes,stringLength)));
if (atLeastOne) emitByte(OP_ADD);
this might belong in a separate issue, but note that brace-escapes (or whatever Python calls them) are currently unavailable as well: