Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a keyword name checking method to hasmethod #30712

Merged
merged 1 commit into from
Jan 25, 2019
Merged

Conversation

ararslan
Copy link
Member

@ararslan ararslan commented Jan 14, 2019

With this change, hasmethod now accepts a tuple of symbols corresponding to keyword argument names to check for when finding a matching method. I came up with this implementation while experimenting with uses for FrankenTuples.

@ararslan ararslan added the keyword arguments f(x; keyword=arguments) label Jan 14, 2019
@ararslan ararslan force-pushed the aa/hasmethod-kws branch 3 times, most recently from 978f3d0 to 1d2feb6 Compare January 17, 2019 21:21
@ararslan
Copy link
Member Author

ararslan commented Jan 18, 2019

Well I've never seen this before on FreeBSD:

      From worker 2:	Assertion failed: (e && ptls->bt_size != 0), function jl_sig_throw, file /usr/home/julia/julia-fbsd-buildbot/worker/freebsdci/build/src/task.c, line 437.
      From worker 2:	
      From worker 2:	signal (6): Abort trap
      From worker 2:	in expression starting at /usr/home/julia/julia-fbsd-buildbot/worker/freebsdci/build/test/subtype.jl:1185
      From worker 2:	_thr_kill at /lib/libc.so.7 (unknown line)
      From worker 2:	__raise at /lib/libc.so.7 (unknown line)
      From worker 2:	abort at /lib/libc.so.7 (unknown line)
      From worker 2:	__assert at /lib/libc.so.7 (unknown line)
      From worker 2:	jl_sig_throw at /usr/home/julia/julia-fbsd-buildbot/worker/freebsdci/build/src/task.c:437
      From worker 2:	unknown function (ip: 0xffffffffffffffff)
      From worker 2:	Allocations: 57738554 (Pool: 57716973; Big: 21581); GC: 133

Log here: https://build.julialang.org/#/builders/68/builds/2242

Surely unrelated so I've restarted the build.

base/reflection.jl Outdated Show resolved Hide resolved
f(x::Int; y=3) = x + y
@test hasmethod(f, Tuple{Int})
@test hasmethod(f, Tuple{Int}, (:y,))
@test !hasmethod(f, Tuple{Int}, (:jeff,))
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

😹

base/reflection.jl Outdated Show resolved Hide resolved
With this change, `hasmethod` now accepts a tuple of symbols
corresponding to keyword argument names to check for when finding a
matching method.
@ararslan
Copy link
Member Author

Looking better?

@ararslan
Copy link
Member Author

Bumpity bump

@StefanKarpinski
Copy link
Sponsor Member

Jeff, if you're cool with this, just merge it.

@JeffBezanson JeffBezanson merged commit 3415875 into master Jan 25, 2019
@JeffBezanson JeffBezanson deleted the aa/hasmethod-kws branch January 25, 2019 16:48
@ararslan
Copy link
Member Author

Thanks guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keyword arguments f(x; keyword=arguments)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants