Skip to content

Custom #\( reader macro breaks #1= #1677

Open
@stassats

Description

@stassats
(let ((*readtable* (copy-readtable)))
  (set-macro-character #\(
                       (lambda (stream ignore)
                         (declare (ignore ignore))
                         (loop for peek = (peek-char t stream t nil t)
                               do
                               (when (eq peek #\))
                                 (read-char stream)
                                 (loop-finish))
                               collect (let* (
                                              (function (get-macro-character peek)))
                                         (cond (function
                                                (read-char stream)
                                                (funcall function stream peek))
                                               (t
                                                (read stream t nil t)))))))
  (load (compile-file "/tmp/foo.lisp")))

With foo.lisp:
(print (quote #1=(member :floor :ceiling)))

; Compiling file: /tmp/foo.lisp
1> (COMPILER::READ-ONE-AST #<CORE:C-FILE-STREAM #P"/tmp/foo.lisp"> NIL #:EOF10173)
;   (MEMBER :FLOOR ...)
<1 (COMPILER::READ-ONE-AST #<CLEAVIR-AST:FUNCTION-AST NIL #<CONCRETE-SYNTAX-TREE:CONS-CST raw: (MEMBER
                                                                                                :FLOOR
                                                                                                :CEILING) @0x7ff6fa7bf399> @0x7ff6fa3cede9> (MEMBER
                                                                                                                                             :FLOOR
                                                                                                                                             :CEILING) #<CORE::SOURCE-POS-INFO :fileId 348 :filepos 0 :lineno 1 :column 0 :function-scope NIL :inlined_at NIL @0x7ff6fde3dfc8>)
1> (COMPILER::READ-ONE-AST #<CORE:C-FILE-STREAM #P"/tmp/foo.lisp"> NIL #:EOF10173)
<1 (COMPILER::READ-ONE-AST NIL NIL NIL)
; caught WARNING:
;   The derived type of <nameless datum>
;   is (VALUES (MEMBER :CEILING) &OPTIONAL &REST NIL)
;   but is asserted as (VALUES &OPTIONAL (OR (CONS T T) (MEMBER NIL)) &REST T)
;   by #<THEI @0x7ff6f1d1c849> in (MEMBER :FLOOR :CEILING).
;     at /tmp/foo.lisp 1:17
; 
; 
; compilation unit finished
;   caught 1 WARNING condition

;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions