summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--llex.c2
-rw-r--r--testes/literals.lua9
2 files changed, 11 insertions, 0 deletions
diff --git a/llex.c b/llex.c
index b0bab377..bb81cec4 100644
--- a/llex.c
+++ b/llex.c
@@ -228,6 +228,8 @@ static int read_numeral (LexState *ls, SemInfo *seminfo) {
228 save_and_next(ls); 228 save_and_next(ls);
229 else break; 229 else break;
230 } 230 }
231 if (lislalnum(ls->current)) /* is numeral touching an alpha num? */
232 save_and_next(ls); /* force an error */
231 save(ls, '\0'); 233 save(ls, '\0');
232 if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */ 234 if (luaO_str2num(luaZ_buffer(ls->buff), &obj) == 0) /* format error? */
233 lexerror(ls, "malformed number", TK_FLT); 235 lexerror(ls, "malformed number", TK_FLT);
diff --git a/testes/literals.lua b/testes/literals.lua
index fc45d4ad..27f9377d 100644
--- a/testes/literals.lua
+++ b/testes/literals.lua
@@ -306,4 +306,13 @@ assert(not load"a = 'non-ending string\n'")
306assert(not load"a = '\\345'") 306assert(not load"a = '\\345'")
307assert(not load"a = [=x]") 307assert(not load"a = [=x]")
308 308
309local function malformednum (n, exp)
310 local s, msg = load("return " .. n)
311 assert(not s and string.find(msg, exp))
312end
313
314malformednum("0xe-", "near <eof>")
315malformednum("0xep-p", "malformed number")
316malformednum("1print()", "malformed number")
317
309print('OK') 318print('OK')