From 8082906c059f2b1473de4363ca57fe19b52f281f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 17 Jul 2019 14:50:42 -0300 Subject: Fixed small issue with constant propagation Constants directly assigned to other constants were not propagating: For instance, in local k1 = 10 local k2 = k1 'k2' were not treated as a compile-time constant. --- testes/code.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'testes') diff --git a/testes/code.lua b/testes/code.lua index b5091458..57923b14 100644 --- a/testes/code.lua +++ b/testes/code.lua @@ -8,7 +8,8 @@ end print "testing code generation and optimizations" -- to test constant propagation -local k0 = 0 +local k0aux = 0 +local k0 = k0aux local k1 = 1 local k3 = 3 local k6 = k3 + (k3 << k0) @@ -410,8 +411,9 @@ checkequal(function () return 6 and true or nil end, do -- string constants + local k0 = "00000000000000000000000000000000000000000000000000" local function f1 () - local k = "00000000000000000000000000000000000000000000000000" + local k = k0 return function () return function () return k end end @@ -419,8 +421,8 @@ do -- string constants local f2 = f1() local f3 = f2() - assert(f3() == string.rep("0", 50)) - checkK(f3, f3()) + assert(f3() == k0) + checkK(f3, k0) -- string is not needed by other functions assert(T.listk(f1)[1] == nil) assert(T.listk(f2)[1] == nil) -- cgit v1.2.3-55-g6feb