You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia>module A1
using LinearAlgebra
struct A endDiagonal(rand(2))
Diagonal(::A) =Diagonal(rand(2))
end
Main.A1
julia>methods(A1.Diagonal)
# 8 methods for type constructor:
[1] LinearAlgebra.Diagonal(::Main.A1.A)
@ Main.A1 REPL[1]:5
[other methods...]
How am I able to add a method to LinearAlgebra.Diagonal without explicitly importing it, or qualifying it by the module name? The docs imply that this is required.
This doesn't work for Base functions, where adding the method fails with an error message stating that one needs to import the function explicitly.
julia>module A1
struct A endsin(2)
sin(::A) =sin(2)
end
ERROR: invalid method definition in A1:function Base.sin must be explicitly imported to be extended
Stacktrace:
[1] top-level scope
@ none:0
[2] top-level scope
@ REPL[1]:4
I think this behavior should extend to other modules as well, and one shouldn't be able to add the method above.
julia>versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-0410:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU:8×11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
WORD_SIZE:64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads:1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
LD_LIBRARY_PATH = :/usr/lib/x86_64-linux-gnu/gtk-3.0/modules
JULIA_EDITOR = subl
The text was updated successfully, but these errors were encountered:
How am I able to add a method to
LinearAlgebra.Diagonal
without explicitlyimport
ing it, or qualifying it by the module name? The docs imply that this is required.This doesn't work for
Base
functions, where adding the method fails with an error message stating that one needs to import the function explicitly.I think this behavior should extend to other modules as well, and one shouldn't be able to add the method above.
The text was updated successfully, but these errors were encountered: