Skip to content

macroexpand crashes on -> with where #58195

@vtjnash

Description

@vtjnash
;; given the LHS of e.g. `x::Int -> y`, wrap the signature in `tuple` to normalize
(define (tuple-wrap-arrow-sig e)
  (cond ((atom? e)             `(tuple ,e))
        ((eq? (car e) 'where)  `(where ,(tuple-wrap-arrow-arglist (cadr e)) ,@(cddr e)))
        ((eq? (car e) 'tuple)  e)
        ((eq? (car e) 'escape) `(escape ,(tuple-wrap-arrow-sig (cadr e))))
        (else                  `(tuple ,e))))

The tuple-wrap-arrow-arglist function does not exist.

MWE

julia> macro x(); return :((() where T) -> ()); end; @x

(unbound-error tuple-wrap-arrow-arglist)
unexpected error: #0 (tuple-wrap-arrow-sig
 (where (tuple) T))
#1 (resolve-expansion-vars-
 (-> (where (tuple) T) (block (line 1 |REPL[3]|) (tuple))) () #<julia: Main>
 ((line 1 |REPL[3]|)) () #f)
ERROR: syntax: malformed expression

(added by Jeff in 646626e with no test so it was always broken)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions