M2 icon indicating copy to clipboard operation
M2 copied to clipboard

`methods Type` exposes unexported methods

Open antonleykin opened this issue 1 year ago • 1 comments

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

antonleykin avatar Feb 05 '24 20:02 antonleykin

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.

mahrud avatar Feb 05 '24 21:02 mahrud

I think that this is not the intended behavior. I think we should only display methods which are exported in their package.

mikestillman avatar Jul 08 '24 19:07 mikestillman

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.)

antonleykin avatar Jul 09 '24 11:07 antonleykin