lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Sep 21, 2021 at 2:15 PM Tomás Guisasola <tomasguisasola@gmail.com> wrote:
Hi Jonathan

> I don't know about "real" real code in the wild that broke, but it's easy to imagine something like this toy example breaking:
>
> local t = {require("mymodule"), require("anothermod"), require("lastmod")}
> assert(#t == 3) -- or code that implicitly assumes #t to be equal to 3

require() will throw an error in case of failure, so it won't reach
assert(), isn't it?

In this toy example, assert() has nothing to do with whether require succeeds. It's just checking that the length of the table t is 3, which is true on earlier version of Lua but false on 5.4 (since both results of require("lastmod") will be used).

This assert is meant as a stand-in for subsequent "real code" that assumes t is a sequence of modules and nothing else.