diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-17 14:50:42 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-17 14:50:42 -0300 |
| commit | 8082906c059f2b1473de4363ca57fe19b52f281f (patch) | |
| tree | 1ef5607d4c2a3dc54777bf882849b0260ca8eb56 /testes/code.lua | |
| parent | d6af81084df569bc8e3bd0949ad6fc0b40c8468d (diff) | |
| download | lua-github-8082906c059f2b1473de4363ca57fe19b52f281f.tar.gz | |
Fixed small issue with constant propagation
Constants directly assigned to other constants were not propagating:
For instance, in
local <const> k1 = 10
local <const> k2 = k1
'k2' were not treated as a compile-time constant.
Diffstat (limited to 'testes/code.lua')
| -rw-r--r-- | testes/code.lua | 10 |
1 files changed, 6 insertions, 4 deletions
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 <const> k0 = 0 +local <const> k0aux = 0 +local <const> k0 = k0aux local <const> k1 = 1 local <const> k3 = 3 local <const> k6 = k3 + (k3 << k0) @@ -410,8 +411,9 @@ checkequal(function () return 6 and true or nil end, do -- string constants + local <const> k0 = "00000000000000000000000000000000000000000000000000" local function f1 () - local <const> k = "00000000000000000000000000000000000000000000000000" + local <const> 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) |
