mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
Syntax should not allow numbers touching identifiers
Code like 'a = 1print()' should not be accepted.
This commit is contained in:
parent
8004798b03
commit
65d1aa7a77
2 changed files with 11 additions and 0 deletions
|
|
@ -306,4 +306,13 @@ assert(not load"a = 'non-ending string\n'")
|
|||
assert(not load"a = '\\345'")
|
||||
assert(not load"a = [=x]")
|
||||
|
||||
local function malformednum (n, exp)
|
||||
local s, msg = load("return " .. n)
|
||||
assert(not s and string.find(msg, exp))
|
||||
end
|
||||
|
||||
malformednum("0xe-", "near <eof>")
|
||||
malformednum("0xep-p", "malformed number")
|
||||
malformednum("1print()", "malformed number")
|
||||
|
||||
print('OK')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue