Skip to content

String interpolation cuts string literals at \0 in some cases #75

@Suzanna-Linn

Description

@Suzanna-Linn

A literal including \0 and a expression:

-- SLua, Beta Grid
print(#`test\0ing{1}`)  -- > 4

Works well in Luau:

-- Luau, Roblox Studio
print(#`test\0ing{1}`)  -- > 9

It could be that Luau is already solving it, if it uses this code:

SLua:

slua/Compiler/src/Compiler.cpp

Lines 1962 to 1965 in fed1a35

if (formatString.empty())
formatStringIndex = bytecode.addConstantString({"", 0});
else
formatStringIndex = bytecode.addConstantString(sref(names.getOrAdd(formatString.c_str(), formatString.size())));

Luau:
https://github.com/luau-lang/luau/blob/40d4815888f63362a6cb79b3e74c4aafa0b2cbf4/Compiler/src/Compiler.cpp#L1991-L2004

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions