-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Unhelpful/confusing error message when extending functions from Base #4070
Comments
Perhaps you need |
The interesting issue here is that |
I should point out, with that change, the Dict lookup in The trouble is that given |
Yes its hard to know where the line is, I agree. But you don't have to give a warning in general, just extend current error message
to also include something like
This way you just give a very helpful hint when the user is getting an error anyway, instead of a warning for every name clash with Base. |
|
That was a good idea; I have implemented it. |
wonderful, thanks. |
Hi, I just happened on this thread while trying to extend rand. The new error message is helpful and it's cool to see the discussion that lead to it! :-) However, The error message I got was:
So, I tried "import Random", but got the error: Based on the discussion above, I tried: "import Base.Random" Which doesn't give an error. Could the warning that you added be more specific and suggest the exact module to import, such as:
Or some such? However, on the REPLY I still can't extend rand (same error. I tried the same in a file, and it does work (although it leads to a stack overflow because the method's calling itself, oops). So there's clearly still lots that I don't understand! |
Does |
On 28 Jan 2015, at 10:44, Tim Holy [email protected] wrote:
Hi Tim, Thanks…
Yeah – I think simply adding the explicit mention of "Base" would be very helpful. I've also noticed that if start the REPL and my first line is:
Then I don't get the module error above, but I do get a stack overflow if I try to call my However, if I call I'm speculating that in the REPL at least, when I call I then provide my implementation and it adds it as another specialisation. When I call Or is it something else? For what it's worth, I found this fairly confusing (although, I hope I'm learning something!) – definitely user error by me, and clearly, I'm clueless and just starting out and out to read more guides, but could this be a less sharp edge? Thanks anyway – I'm finding the language terrific!= |
Stdlib: Pkg URL: https://github.com/JuliaLang/Pkg.jl.git Stdlib branch: master Julia branch: master Old commit: 7b759d7f0 New commit: d84a1a38b Julia version: 1.12.0-DEV Pkg version: 1.12.0 Bump invoked by: @KristofferC Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaLang/Pkg.jl@7b759d7...d84a1a3 ``` $ git log --oneline 7b759d7f0..d84a1a38b d84a1a38b Allow use of a url and subdir in [sources] (#4039) cd75456a8 Fix heading (#4102) b61066120 rename FORMER_STDLIBS -> UPGRADABLE_STDLIBS (#4070) 814949ed2 Increase version of `StaticArrays` in `why` tests (#4077) 83e13631e Run CI on backport branch too (#4094) ``` Co-authored-by: Dilum Aluthge <[email protected]>
importing the module quoted below and calling
HeldoutDatasets.HoldoutIndex(10,0.2)
gave me the error
ERROR: no method getindex(Dict{Any,Any},Int64)
in HoldoutIndex at HeldoutDatasets.jl:23
which I find completely confusing and very hard to debug. Removing the
module HeldoutDatasets
declaration gave the following much clearer Error:ERROR: error in method definition: function Base.getindex must be explicitly imported to be extended
in include_from_node1 at loading.jl:92
in reload_path at loading.jl:117
in reload at loading.jl:59
at HeldoutDatasets.jl:43
The text was updated successfully, but these errors were encountered: