-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid escape sequences #152
Comments
I think it should still be an error, but it's possible to have luacheck errors and warnings in the same file already (invalid inline options are also reported as errors). Luacheck should just check the file anyway if there are invalid escape sequences. Same in general if it can recover from a syntax error, but that's more difficult. One problem with this is that dropping an invalid escape sequence from a string literal changes its value, which can result in extra warnings in some cases: local t = {
["\x00"] = "one embedded zero",
["\x00\x00"] = "two embedded zeros", -- Warning: unused field, always overwritten on the next line
["\x00\x00\xoo"] = "three embedded zeros"
} But the advantages of having all the checks run even with invalid escape sequences outweigh this. |
Couldnt regular expressions be treated as correct at least? we get
at
|
@rubo77, your code is actually wrong though. The Lua interpreter produces a syntax error saying Syntactly speaking, all Lua string literals are treated the same, no mater whether they are intended to be used as Lua patterns, regex patterns for an external library, or just a regular old string. If you want to use Lua pattern matching functions like If you are using an external regex library with PCRE syntax, where the escape character is the backslash, then you need to escape the backslash inside the Lua string literal, just like you would have to do in any other language that doesn't have special syntax for regular expression literals. That is, you would need to use |
Invalid escape sequences should be warnings instead of errors, since the file still can be compiled regardless.
The text was updated successfully, but these errors were encountered: