Skip to content

os.time / os.date / os.clock / os.difftime missing from stdlib #280

Closed

Description

@davydog187

Symptom

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).

Related

Activity

  1. added
    bugSomething isn't working
    direction:ADirection A: suite triage to 0.5.0
    kind:suiteLua 5.3 official test suite work
    on May 28, 2026
  2. added 2 commits that reference this issue on May 31, 2026
    1c1a652
    a030c90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdirection:ADirection A: suite triage to 0.5.0kind:suiteLua 5.3 official test suite work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions