Skip to content

Problem interpreting vanilla lua strings with Z escapes #322

@dorpg9

Description

@dorpg9

As stated in the lua manual, strings can haze \z escape sequences in normal quoted strings, which skips the whitespaces that follow after it, including literal newlines. However, it seems that darklua does not recognize this and throws malformed string errors. The bug was encounteres when I was running darklua 0.17.2 installed via Rokit.

src/shared/testDarkLuaBeingSilly.luau

local validString ="\z
	This should be a perfectly valid string."

print(validString)

VS Code task command

darklua process --config .darklua.json src/shared/testDarkLuaBeingSilly.luau builds/testDarkLuaBeingSilly.luau;code -r builds/testDarkLuaBeingSilly.luau 

Terminal Output

error occurred while tokenizing: unclosed string (1:20 to 2:1)
error occurred while creating ast: unexpected token `should`. (starting from line 2, character 7 and ending on line 2, character 13)
additional information: unexpected expression when looking for a statement
error occurred while creating ast: unexpected token `be`. (starting from line 2, character 14 and ending on line 2, character 16)
additional information: unexpected expression when looking for a statement
error occurred while creating ast: unexpected token `a`. (starting from line 2, character 17 and ending on line 2, character 18)
additional information: unexpected expression when looking for a statement
error occurred while creating ast: unexpected token `perfectly`. (starting from line 2, character 19 and ending on line 2, character 28)
additional information: unexpected expression when looking for a statement
error occurred while creating ast: unexpected token `valid`. (starting from line 2, character 29 and ending on line 2, character 34)
additional information: unexpected expression when looking for a statement
error occurred while creating ast: unexpected token `string`. (starting from line 2, character 35 and ending on line 2, character 41)
additional information: unexpected expression when looking for a statement
error occurred while creating ast: unexpected token `.`. (starting from line 2, character 41 and ending on line 2, character 42)
additional information: expected identifier after `.`
error occurred while creating ast: unexpected token `""`. (starting from line 2, character 42 and ending on line 2, character 44)
additional information: unexpected expression when looking for a statement
error occurred while tokenizing: unclosed string (2:42 to 2:44)
error occurred while creating ast: unexpected token `""`. (starting from line 2, character 42 and ending on line 2, character 44)
additional information: unexpected token, this needs to be a statement

The output file is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions