Long string inconsistency compared to CC:Tweaked
MichielP1807 opened this issue · comments
Describe the bug
In Lua, strings can be using long brackets. E.g. [[a]]
represents a string equal to "a"
. The Lua documentation says that "they can contain anything except a closing bracket of the proper level." However, in Lua 5.1 it seems that they cannot contain a starting bracket of the proper level either, as this will result in a syntax error. In newer versions of Lua this does not seem to be the case.
This inconsistency leads to different behaviors in CraftOS-PC versus CC:Tweaked. CC:Tweaked will produce a syntax error when writing e.g. [[a[[b]]
, similar to Lua 5.1. CraftOS-PC will accept it as a string equal to "a[[b"
, similar to Lua 5.2.
To Reproduce
Steps to reproduce the behavior:
- Open the interactive Lua console
- Type
return [[a[[b]]
- See results: a syntax error if using CC:Tweaked, or a string equal to
"a[[b"
if using CraftOS-PC
Expected behavior
The behavior seen with Lua 5.1 (which is what we also see in CC:Tweaked) could be considered a bug as it doesn't match what the documentation says. However, we expect CraftOS-PC to produce the same results as CC:Tweaked.
Environment
- OS: Any (tested on Windows 10 & Ubuntu)
- CraftOS-PC Version: v2.8.2, both Accelerated and normal version
- Compiled from source? No
Additional context
I found this bug while wondering why I couldn't unserialise a string with CC:Tweaked, while it did work in CraftOS-PC. In turns out it was because of the opening long brackets that appeared in the string.
I assume that this inconsistent behavior would also be fixed by fixing how CraftOS-PC handles the long brackets.
Fixed in c819d6b