Skip to content

Commit

Permalink
fix #27807, hygiene issue in static parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 28, 2018
1 parent c404bb7 commit e2de9b3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/macroexpand.scm
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@
;; function definition
(pattern-lambda (function (-$ (call name . argl) (|::| (call name . argl) _t)) body)
(cons 'varlist (safe-llist-positional-args (fix-arglist argl))))
(pattern-lambda (function (where (-$ (call name . argl) (|::| (call name . argl) _t)) . wheres) body)
(cons 'varlist (append (safe-llist-positional-args (fix-arglist argl))
(typevar-names wheres))))
(pattern-lambda (function (where callspec . wheres) body)
(let ((others (pattern-expand1 vars-introduced-by-patterns `(function ,callspec ,body))))
(cons 'varlist (append (if (and (pair? others) (eq? (car others) 'varlist))
(cdr others)
'())
(typevar-names wheres)))))

(pattern-lambda (function (tuple . args) body)
`(-> (tuple ,@args) ,body))
Expand All @@ -71,7 +74,7 @@
`(function (call (curly ,name . ,sparams) . ,argl) ,body))
(pattern-lambda (= (-$ (call name . argl) (|::| (call name . argl) _t)) body)
`(function (call ,name ,@argl) ,body))
(pattern-lambda (= (where (-$ (call name . argl) (|::| (call name . argl) _t)) . wheres) body)
(pattern-lambda (= (where callspec . wheres) body)
(cons 'function (cdr __)))

;; anonymous function
Expand Down Expand Up @@ -150,14 +153,14 @@

(pattern-lambda (function (-$ (call name . argl) (|::| (call name . argl) _t)) body)
(cons 'varlist (safe-llist-keyword-args (fix-arglist argl))))
(pattern-lambda (function (where (-$ (call name . argl) (|::| (call name . argl) _t)) . wheres) body)
(cons 'varlist (safe-llist-keyword-args (fix-arglist argl))))
(pattern-lambda (function (where callspec . wheres) body)
`(function ,callspec ,body))

(pattern-lambda (= (call (curly name . sparams) . argl) body)
`(function (call (curly ,name . ,sparams) . ,argl) ,body))
(pattern-lambda (= (-$ (call name . argl) (|::| (call name . argl) _t)) body)
`(function (call ,name ,@argl) ,body))
(pattern-lambda (= (where (-$ (call name . argl) (|::| (call name . argl) _t)) . wheres) body)
(pattern-lambda (= (where callspec . wheres) body)
(cons 'function (cdr __)))
))

Expand Down
12 changes: 12 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1489,3 +1489,15 @@ let val(::Type{Val{X}}) where {X} = X, f
end
@test val(first(methods(f())).sig.parameters[2])(21) == 42
end

# issue #27807
module A27807
macro m()
quote
function foo(x::T, y::S) where T<:Number where S<:Number
return one(T), zero(S)
end
end
end
end
@test A27807.@m()(1,1.0) === (1, 0.0)

2 comments on commit e2de9b3

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.