exaloop / codon

A high-performance, zero-overhead, extensible Python compiler using LLVM
https://docs.exaloop.io/codon
Other
15.19k stars 522 forks source link

f-string left-justify problem #304

Open ianxek opened 1 year ago

ianxek commented 1 year ago

This is unsupported (print 30 times the character =)

print(f"{'':=<30}")
bug.py:1:5: error: syntax error, unexpected '<'
lewisfogden commented 1 year ago

I think it is failing because Codon is detecting the = as the alignment, whereas per the spec it is the fill character. If you change = to ~ for example it works and is detected as the fill (the fill is optional on top of the optional align).

I think the logic might need updated to check that if a further align character is found ("<" | ">" | "=" | "^") then the first one is interpreted as the fill.

format_spec ::= [[fill]align][sign][z][#][0][width][grouping_option][.precision][type]

https://docs.python.org/3/library/string.html#format-specification-mini-language

inumanag commented 3 weeks ago

Oh, good one—thank you for the report!