GNU bug report logs - #67239
30.0.50; 30.0.50: Error in nativecomp

Previous Next

Package: emacs;

Reported by: Imran Khan <contact <at> imrankhan.live>

Date: Fri, 17 Nov 2023 13:15:02 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Andrea Corallo <acorallo <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 67239 <at> debbugs.gnu.org, Imran Khan <contact <at> imrankhan.live>
Subject: bug#67239: 30.0.50; 30.0.50: Error in nativecomp
Date: Sat, 02 Dec 2023 04:44:03 -0500
Andrea Corallo <acorallo <at> gnu.org> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Imran Khan <contact <at> imrankhan.live>
>>> Date: Fri, 17 Nov 2023 19:13:46 +0600
>>> 
>>> 
>>> Hello, I have come across a function that gives error when native
>>> compiled, but works fine when byte compiled.  The issue arose when using
>>> a third-party library (ts-format function in ts.el):
>>> 
>>> https://github.com/alphapapa/ts.el/blob/master/ts.el
>>> 
>>> But I have curved out the code so that you hopefully don't need to
>>> install that.
>>> 
>>> Reproduction under `emacs -Q`:
>>> 
>>> 1. First library "my-time.el" looks like:
>>> 
>>> ```
>>> ;;; -*- lexical-binding: t; -*-
>>> 
>>> (require 'cl-lib)
>>> 
>>> (cl-defstruct time
>>>   unix)
>>> 
>>> (defvar time-default-format "%Y-%m-%d %H:%M:%S %z"
>>>   "Default format for `time-format'.")
>>> 
>>> (defsubst time-format (&optional time-or-format-string time)
>>>   "Format timestamp with `format-time-string'.
>>> If TS-OR-FORMAT-STRING is a timestamp or nil, use the value of
>>> `time-default-format'.  If both TS-OR-FORMAT-STRING and TS are nil,
>>> use the current time."
>>>   (cl-etypecase time-or-format-string
>>>     (time (format-time-string time-default-format (time-unix time-or-format-string)))
>>>     (string (cl-etypecase time
>>>               (time (format-time-string time-or-format-string (time-unix time)))
>>>               (null (format-time-string time-or-format-string))))
>>>     (null (cl-etypecase time
>>>             (time (format-time-string time-default-format (time-unix time)))
>>>             (null (format-time-string time-default-format))))))
>>> 
>>> (provide 'my-time)
>>> ```
>>> 
>>> 2. Then there is my code "my-bug.el":
>>> 
>>> ```
>>> ;;; -*- lexical-binding: t -*-
>>> 
>>> (require 'my-time)
>>> 
>>> (defun my-bug ()
>>>   (let ((time (make-time :unix (time-convert (current-time) 'integer))))
>>>     ;; (message (time-format time)) ;; one argument works fine
>>>     (message (time-format "%F" time)) ;; but this says: (wrong-type-argument stringp time)
>>>     ))
>>> 
>>> (provide 'my-bug)
>>> ```
>>> 
>>> 3. When both of these are native compiled, doing `M-: (my-bug)` gives:
>>> ```
>>> Debugger entered--Lisp error: (wrong-type-argument stringp time)
>>>   my-bug()
>>>   eval-expression((my-bug) nil nil 127)
>>>   funcall-interactively(eval-expression (my-bug) nil nil 127)
>>>   command-execute(eval-expression)
>>> ```
>>> 
>>> 4. But if I C-M-x on `my-bug` manually, it works fine.
>>> 
>>> As far as I can tell, under 29.1 it worked fine under nativecomp too.
>>
>> Adding Andrea to the discussion.
>
> Thanks will look at.
>
>   Andrea

Quick update, didn't had much time and wans't trivial but I've a fix
that is under test.  I'll be pushing it when done.

Thanks

  Andrea




This bug report was last modified 1 year and 226 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.