You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
os.time() (and os.date, os.clock, os.difftime) raise "attempt to call a nil value (field 'X' on global 'os')". The os table itself exists — it is auto-allocated by the default sandbox in lib/lua.ex:45-50 to host the raise-on-call stubs for os.execute/exit/getenv/remove/rename/tmpname — but no actual os.* functions are installed.
Repro
print(type(os)) -- "table"print(type(os.time)) -- "nil"_ENV.GLOB1=math.floor(os.time()) %2-- runtime type error
Blocks test/lua53_tests/constructs.lua at line 237.
Where the gap is
lib/lua/vm/stdlib.ex:22-56 installs String, Math, Table, Utf8, and Debug libraries — no Os. There is no lib/lua/vm/stdlib/os.ex.
The sandbox in lib/lua.ex only knows about the side-effectful entries (execute, exit, getenv, remove, rename, tmpname); the side-effect-free helpers (time, date, clock, difftime) need their own stdlib install path.
Proposed scope
Add Lua.VM.Stdlib.Os mirroring the layout of Lua.VM.Stdlib.Math. Minimum surface:
Function
Notes
os.time([table])
seconds since epoch; mirrors :os.system_time(:second) for the no-arg form
os.date([format[, time]])
format strings *t, !*t, and %-format via :calendar / Calendar.strftime
os.clock()
CPU time in seconds (:erlang.statistics(:runtime))
os.difftime(t2, t1)
trivial subtract
os.getenv(name)
safe to stub — returns nil always (the sandbox entry still raises if not excluded)
os.execute, os.exit, os.remove, os.rename, os.tmpname stay sandboxed by default.
Suite impact
Unlocks lines 237..248 of constructs.lua immediately. May also progress other suite files that touch os.time for seeding (math.lua sometimes does).
Activity
fix(stdlib): make os.clock non-negative on first call
chore(A43): rename os-library plan from A21a to A43