MCJack123 / craftos2

A fast, modern, and feature-filled ComputerCraft emulator written in C++.

Home Page:https://www.craftos-pc.cc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

image

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:

  1. Open the interactive Lua console
  2. Type return [[a[[b]]
  3. 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.

CC:Tweaked:
image

CraftOS-PC:
image

I assume that this inconsistent behavior would also be fixed by fixing how CraftOS-PC handles the long brackets.