Minor typo in error message

60 views
Skip to first unread message

Martin Eden

unread,
Jul 12, 2026, 10:36:47 AM (12 days ago) Jul 12
to lu...@googlegroups.com
In Lua 5.5 when you try to use string with invalid
escape sequence -- error message lacks closing quote.

For example let's try invalid escape code "\c":

  Lua 5.5.0  Copyright (C) 1994-2025 Lua.org, PUC-Rio
  > '\c'
  stdin:1: invalid escape sequence near ''\c'

I believe it should end on "''\c''".

Message for invalid decimal codes is correct:

  > '\999'
  stdin:1: decimal escape too large near ''\999''

But not for "\999a":

  > '\999a'
  stdin:1: decimal escape too large near ''\999a'

-- Martin

Roberto Ierusalimschy

unread,
Jul 12, 2026, 3:27:44 PM (12 days ago) Jul 12
to 'Martin Eden' via lua-l
> In Lua 5.5 when you try to use string with invalid
> escape sequence -- error message lacks closing quote.
>
> For example let's try invalid escape code "\c":
>
>   Lua 5.5.0  Copyright (C) 1994-2025 Lua.org, PUC-Rio
>   > '\c'
>   stdin:1: invalid escape sequence near ''\c'
>
> I believe it should end on "''\c''".

The closing quote is not part of the invalid escape sequence, why it
must be in the error message? Note that the closing quote can be
quite far away, or it may not even exist:

> '\caaaaaaaaaaaaaaaaaaaaaaaaaa'
stdin:1: invalid escape sequence near ''\c'
> '\caaaaaaaaaaaaaaaaaaa
stdin:1: invalid escape sequence near ''\c'

Lua stops reading as soon as it finds an error.

-- Roberto

Martin Eden

unread,
Jul 13, 2026, 12:07:53 AM (12 days ago) Jul 13
to lu...@googlegroups.com
On 2026-07-12 21:27, Roberto Ierusalimschy wrote:
> The closing quote is not part of the invalid escape sequence, why it
> must be in the error message? Note that the closing quote can be
> quite far away, or it may not even exist:
>
> [...]
>
> Lua stops reading as soon as it finds an error.
Thank you for clarification, Roberto.

Now I understood that error message is from lexer
which just prints single quote, read buffer contents, single quote.

Was distracted by single quotes in my case.

  > "kinda long too\999a"
  stdin:1: decimal escape too large near '"kinda long too\999a'

-- Martin

TopchetoEU

unread,
Jul 13, 2026, 6:15:08 AM (11 days ago) Jul 13
to 'Martin Eden' via lua-l
> ---

I'm not sure how much this is within the realm of possibility, but would it
make sense to quote the erroneous part of the source like this: `'bad escape
\c`, so that one doesn't get confused by the repeated single quotes?




Reply all
Reply to author
Forward
0 new messages