From 65d1aa7a779b30bf5b0e7b968b3980b702b08b2c Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 9 Apr 2019 18:40:39 -0300 Subject: Syntax should not allow numbers touching identifiers Code like 'a = 1print()' should not be accepted. --- testes/literals.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'testes') 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'") 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 ") +malformednum("0xep-p", "malformed number") +malformednum("1print()", "malformed number") + print('OK') -- cgit v1.2.3-55-g6feb