kyren / piccolo

An experimental stackless Lua VM implemented in pure Rust
Creative Commons Zero v1.0 Universal
1.62k stars 59 forks source link

Multiline strings aren't removing the initial newline #71

Closed Jengamon closed 3 months ago

Jengamon commented 3 months ago

Found a thing:

print "---"
print [[
Random
]]

This prints

---

Random

in Piccolo, but

---
Random

in Lua.

From the Lua Reference Manual "Literal strings can also be defined using a long format enclosed by long brackets. [...] Literals in this bracketed form can run for several lines, do not interpret any escape sequences, and ignore long brackets of any other level. Any kind of end-of-line sequence (carriage return, newline, carriage return followed by newline, or newline followed by carriage return) is converted to a simple newline. When the opening long bracket is immediately followed by a newline, the newline is not included in the string."

kyren commented 3 months ago

This and a related issue should be fixed by 7405b4e2dea004aad0c43d765a9181220f33a5dd