First implementation for 'const' variables

A variable can be declared const, which means it cannot be assigned to,
with the syntax 'local <const> name = exp'.
This commit is contained in:
Roberto Ierusalimschy
2019-05-17 11:11:44 -03:00
parent 347d6961ac
commit d9f40e3f6f
7 changed files with 207 additions and 58 deletions

View File

@@ -3,10 +3,10 @@
print("testing numbers and math lib")
local minint = math.mininteger
local maxint = math.maxinteger
local <const> minint = math.mininteger
local <const> maxint = math.maxinteger
local intbits = math.floor(math.log(maxint, 2) + 0.5) + 1
local <const> intbits = math.floor(math.log(maxint, 2) + 0.5) + 1
assert((1 << intbits) == 0)
assert(minint == 1 << (intbits - 1))