diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-04-25 14:42:51 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-04-25 14:42:51 -0300 |
| commit | c764ca71a639f5585b5f466bea25dc42b855a4b0 (patch) | |
| tree | 0caf66be3a21dbba591d2d16cdf201e83f37d7b0 /testes | |
| parent | 295cde94545b00afc8624bd388db805504d356bd (diff) | |
| download | lua-c764ca71a639f5585b5f466bea25dc42b855a4b0.tar.gz lua-c764ca71a639f5585b5f466bea25dc42b855a4b0.tar.bz2 lua-c764ca71a639f5585b5f466bea25dc42b855a4b0.zip | |
Bug: Wrong code generation in bitwise operations
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/constructs.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testes/constructs.lua b/testes/constructs.lua index a74a8c04..0d9ec92d 100644 --- a/testes/constructs.lua +++ b/testes/constructs.lua | |||
| @@ -103,6 +103,31 @@ do -- test old bug (first name could not be an `upvalue') | |||
| 103 | local a; function f(x) x={a=1}; x={x=1}; x={G=1} end | 103 | local a; function f(x) x={a=1}; x={x=1}; x={G=1} end |
| 104 | end | 104 | end |
| 105 | 105 | ||
| 106 | |||
| 107 | do -- bug since 5.4.0 | ||
| 108 | -- create code with a table using more than 256 constants | ||
| 109 | local code = {"local x = {"} | ||
| 110 | for i = 1, 257 do | ||
| 111 | code[#code + 1] = i .. ".1," | ||
| 112 | end | ||
| 113 | code[#code + 1] = "};" | ||
| 114 | code = table.concat(code) | ||
| 115 | |||
| 116 | -- add "ret" to the end of that code and checks that | ||
| 117 | -- it produces the expected value "val" | ||
| 118 | local function check (ret, val) | ||
| 119 | local code = code .. ret | ||
| 120 | code = load(code) | ||
| 121 | assert(code() == val) | ||
| 122 | end | ||
| 123 | |||
| 124 | check("return (1 ~ (2 or 3))", 1 ~ 2) | ||
| 125 | check("return (1 | (2 or 3))", 1 | 2) | ||
| 126 | check("return (1 + (2 or 3))", 1 + 2) | ||
| 127 | check("return (1 << (2 or 3))", 1 << 2) | ||
| 128 | end | ||
| 129 | |||
| 130 | |||
| 106 | function f (i) | 131 | function f (i) |
| 107 | if type(i) ~= 'number' then return i,'jojo'; end; | 132 | if type(i) ~= 'number' then return i,'jojo'; end; |
| 108 | if i > 0 then return i, f(i-1); end; | 133 | if i > 0 then return i, f(i-1); end; |
