[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#67239: 30.0.50; 30.0.50: Error in nativecomp
From: |
Andrea Corallo |
Subject: |
bug#67239: 30.0.50; 30.0.50: Error in nativecomp |
Date: |
Fri, 17 Nov 2023 15:50:13 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Imran Khan <contact@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