M2
M2 copied to clipboard
`methods Type` exposes unexported methods
For a package containing an unexported method bla defined for an exported type T we have methods T listing bla.
The lines to blame involve calling pairs T and were last touched here:
https://github.com/Macaulay2/M2/commit/2bc8cd340166a4f397ad8979c9594b3bfe4246a0
... but they probably existed before this commit.
Here is a self-contained example by @mikestillman
i1 : newPackage "Foo"
o1 = Foo
o1 : Package
i2 : xmethod = method()
o2 = xmethod
o2 : MethodFunction
i3 : Frob = new Type of HashTable
o3 = Frob
o3 : Type
i4 : xmethod Frob := x -> x
o4 = -*Function[stdio:4:18-4:21]*-
o4 : FunctionClosure
i5 : export "Frob"
o5 = {Frob}
o5 : List
i8 : endPackage "Foo"
o8 = Foo
o8 : Package
i9 : methods Frob
o9 = {0 => (xmethod, Frob)}
o9 : NumberedVerticalList
i10 : methods Foo
o10 = {}
o10 : NumberedVerticalList
I believe this is intended behavior and predates my change, unless I'm missing something? e.g. if you enter methods ZZ you get:
{299 => (editMethod, ZZ) }
which is not exported. The only methods that are excluded are those that contain unexported types like RawRingElement.
Also to be clear, I'm fine with changing it so these methods are unlisted, but that might cause some issues.
I think that this is not the intended behavior. I think we should only display methods which are exported in their package.
It would be natural that methods should show only callable methods associated with a type. (If a package is not loaded, then none of its methods show. On the other hand when debug Package, we should see unexported methods that we can call.)
(Note: we have about that outputs way more than methods.)