Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
346 stars 231 forks source link

bug in simple doc or during creation of a method #2867

Open mikestillman opened 1 year ago

mikestillman commented 1 year ago

The following code (note the return type is ideal, not Ideal!) gives an error during installPackage. Removing the doc node, or changing the return type to Ideal both work correctly. Perhaps when creating a method, we should make sure the suggested return type is a type?

-- DocBug.m2
newPackage(
    "DocBug",
    Version => "0.1",
    Date => "8 June 2023",
    Headline => "bug in Core",
    AuxiliaryFiles => false,
    DebuggingMode => true
    )

export {"myfun"}

myfun = method()
myfun(ZZ) := ideal => n -> (
    ideal 0_ZZ
    )

beginDocumentation()

doc ///
    Key
        (myfun, ZZ)
    Headline
        compute
    Usage
        myfun n 
///

end--

-* Development section *-
restart
debug needsPackage "DocBug"
check "DocBug"

uninstallPackage "DocBug"
restart
installPackage "DocBug"
viewHelp "DocBug"
mahrud commented 1 year ago

This is already checked when creating a method with method(TypicalValue => T) here: https://github.com/Macaulay2/M2/blob/8df01f4b5fd75a15bd1004306185afd55241cc3c/M2/Macaulay2/m2/methods.m2#L182-L185

This needs to be fixed in https://github.com/Macaulay2/M2/blob/8df01f4b5fd75a15bd1004306185afd55241cc3c/M2/Macaulay2/d/hashtables.dd#L374 and https://github.com/Macaulay2/M2/blob/8df01f4b5fd75a15bd1004306185afd55241cc3c/M2/Macaulay2/d/hashtables.dd#L408

For starters, what is the difference between those two functions?