diff options
| -rw-r--r-- | llex.c | 2 | ||||
| -rw-r--r-- | testes/literals.lua | 9 |
2 files changed, 11 insertions, 0 deletions
| @@ -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'") | |||
| 306 | assert(not load"a = '\\345'") | 306 | assert(not load"a = '\\345'") |
| 307 | assert(not load"a = [=x]") | 307 | assert(not load"a = [=x]") |
| 308 | 308 | ||
| 309 | local function malformednum (n, exp) | ||
| 310 | local s, msg = load("return " .. n) | ||
| 311 | assert(not s and string.find(msg, exp)) | ||
| 312 | end | ||
| 313 | |||
| 314 | malformednum("0xe-", "near <eof>") | ||
| 315 | malformednum("0xep-p", "malformed number") | ||
| 316 | malformednum("1print()", "malformed number") | ||
| 317 | |||
| 309 | print('OK') | 318 | print('OK') |
