Skip to content

fix(lisp): Don't assume a list representation in `eask-current-time' - #432

Open
alberti42 wants to merge 2 commits into
emacs-eask:masterfrom
alberti42:fix/current-time-representation
Open

fix(lisp): Don't assume a list representation in `eask-current-time'#432
alberti42 wants to merge 2 commits into
emacs-eask:masterfrom
alberti42:fix/current-time-representation

Conversation

@alberti42

Copy link
Copy Markdown

Fixes #431.

Cause

eask-current-time rebuilt a seconds count out of the first two elements of current-time:

(defun eask-current-time ()
  "Return current time."
  (let ((now (current-time))) (logior (ash (car now) 16) (cadr now))))

That assumes current-time returns a (HIGH LOW USEC PSEC) list. The representation is not guaranteed: it depends on current-time-list, which defaults to nil as of Emacs 32, so current-time returns a (TICKS . HZ) cons cell instead.

;; Emacs 31 and earlier, or current-time-list = t
(current-time)  ;; => (27280 7881 699623 0)

;; Emacs 32 default
(current-time)  ;; => (1787829961699629000 . 1000000000)

With the cons cell, cdr is the plain integer 1000000000, so (cadr now) evaluates (car 1000000000) and signals. That integer is HZ, the unit of the tick count, which is why the reported error reads:

Wrong type argument: listp, 1000000000

Because eask-current-time is used to build the directory recipe, eask package aborts before producing an artifact.

Fix

Use float-time, which accepts either representation. time-convert would be the more direct API, but it requires Emacs 27.1 and eask-required-emacs-version is 26.1, so float-time is used instead. float-time has existed since Emacs 21.

The result is unchanged for the list representation:

current-time-list = t:  legacy = 1787830323   float-time = 1787830323   identical

Integer seconds are represented exactly by a double up to roughly 9e15, so there is no precision concern for epoch timestamps.

I checked the rest of the tree: this was the only place a timestamp was decomposed by hand. The other current-time call sites in lisp/_prepare.el go through time-subtract and float-time, and the vendored package-build copies use float-time or current-time-string, all of which accept both representations.

Verification

On GNU Emacs 32.0.50 (development build, 26 August 2026), with Eask 0.12.9 and this patch applied to the installed lisp/_prepare.el:

  • Before: eask package fails with Wrong type argument: listp, 1000000000.
  • After: eask package and eask install both succeed.

I verified it against a real project rather than a synthetic one, using lsp-mode, whose CI is currently blocked by this bug on all Unix Emacs snapshot jobs. With this patch, lsp-mode builds with no changes on its side, so the workaround it needs today (setting current-time-list back to t in its Eask file) can be removed once this is released.

`eask-current-time' rebuilt a seconds count from the first two elements
of `current-time'. That representation is not guaranteed: it depends on
`current-time-list', which defaults to nil as of Emacs 32, so
`current-time' returns a (TICKS . HZ) cons cell rather than a
(HIGH LOW USEC PSEC) list.

`(cadr now)' then evaluates `(car 1000000000)', and `eask package' aborts
with "Wrong type argument: listp, 1000000000", where the number is the HZ
value from the cons cell.

Use `float-time', which accepts either representation and is available in
every Emacs version Eask supports (the declared floor is 26.1, so
`time-convert' is not an option). The result is unchanged for the list
representation.

Fixes emacs-eask#431.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 27, 2026
@alberti42

Copy link
Copy Markdown
Author

Since the workflow runs on this PR are held at action_required, here is the verification I was able to do locally, in case it helps decide whether to approve them.

The project's own test suite

test/jest/install.test.js exercises eask package, so it covers the affected code path. I ran it twice on the same machine, with the same command, changing only lisp/_prepare.el:

npm ci
npm run test-reset
ALLOW_UNSAFE=1 EASK_COMMAND="node $PWD/eask.js" npx jest test/jest/install.test.js
lisp/_prepare.el Result
upstream/master 2 failed, 15 passed, 1 skipped — Wrong type argument: listp, 1000000000
this PR 0 failed, 17 passed, 1 skipped

EASK_COMMAND is set because test/jest/helpers.js defaults to the eask on PATH; without it the suite would test an installed Eask rather than the working tree.

Environment: GNU Emacs 32.0.50 (development build, 26 August 2026), macOS arm64, Node 26.5.0.

Other checks

  • lisp/_prepare.el byte-compiles to t with no warning on the changed lines. The remaining free-variable warnings in that file are pre-existing and unrelated.
  • The return value is unchanged for the list representation. With current-time-list bound to t, the old expression and (floor (float-time)) both yield 1787830323.
  • time-convert would be the more direct API but requires Emacs 27.1, and eask-required-emacs-version is 26.1, so float-time is used instead. It has existed since Emacs 21.
  • I checked the rest of the tree for the same assumption. This was the only place a timestamp is decomposed by hand; the other current-time call sites go through time-subtract, float-time, or current-time-string, which accept either representation.

Check against a real project

lsp-mode is currently unable to build on all of its Unix Emacs snapshot CI jobs because of this bug. With this patch applied to the installed Eask, and with lsp-mode's own Eask file left exactly as it is upstream (no workaround), both commands succeed:

(Built in .../dist/lsp-mode-10.0.1.tar)
(Installed in .../.eask/32.0.50/elpa/lsp-mode-10.0.1/)

So this change alone is sufficient, and the temporary (setq current-time-list t) that lsp-mode needs today (emacs-lsp/lsp-mode#5111) can be dropped once a release includes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eask package fails under Emacs 32 snapshot because of current-time changes

1 participant