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

fix typo in Base.digits #25946

Merged
merged 1 commit into from
Feb 8, 2018
Merged

fix typo in Base.digits #25946

merged 1 commit into from
Feb 8, 2018

Conversation

gsoleilhac
Copy link
Contributor

Also adds deprecations for digits forgotten by #25647

Also adds depreciations for digits forgotten by JuliaLang#25647
Copy link
Member

@StefanKarpinski StefanKarpinski left a comment

Choose a reason for hiding this comment

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

Looks good. Would you mind adding a test for this method?

@ararslan
Copy link
Member

ararslan commented Feb 8, 2018

What's odd is that this is valid syntax, and indeed these methods are already covered by tests.

julia> f(x = x::Int = 1) = 1
f (generic function with 2 methods)

julia> f(1)
1

julia> f()
1

@mbauman
Copy link
Member

mbauman commented Feb 8, 2018

Yeah, it looks like f(; x = y = 1) creates a y binding that is only available within other keywords — it cannot be used within the function body but it can be used in defining other keywords. It's a little strange, but it's consistent with how keywords generally work.

@ararslan ararslan merged commit 24ec0f6 into JuliaLang:master Feb 8, 2018
@ararslan
Copy link
Member

ararslan commented Feb 8, 2018

Thanks for the contribution, @gsoleilhac!

@StefanKarpinski
Copy link
Member

Oh, that is very weird. I wonder if it was intentional. @JeffBezanson?

@gsoleilhac
Copy link
Contributor Author

gsoleilhac commented Feb 8, 2018

I also noticed this, is it expected ?

julia> y
ERROR: UndefVarError: y not defined

julia> f(;x = y = 1) = x, y
f (generic function with 1 method)

julia> f(x = y = 1)
(1, 1)

julia> x
ERROR: UndefVarError: x not defined

julia> y
1

And methods(f) (or tab-completion) is definitevely wrong/misleading :

julia> methods(f)
# 1 method for generic function "f":
f(; x, y) in Main at REPL[1]:1

julia> f(x=1, y=2)
ERROR: MethodError: no method matching f(; x=1, y=2)
Closest candidates are:
  f(; x, y) at REPL[1]:1
Stacktrace:
 [1] (::#kw##f)(::Array{Any,1}, ::#f) at .\<missing>:0

@StefanKarpinski
Copy link
Member

That's definitely a bug.

@gsoleilhac gsoleilhac deleted the gs/fix-typo branch February 11, 2018 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants