M2 icon indicating copy to clipboard operation
M2 copied to clipboard

Spurious layers when debugging

Open mahrud opened this issue 3 years ago • 2 comments

When debugging an error in a method call, particular if the method had options, I often have to repeatedly enter end several times, going through the same exact lines that are unrelated to the error:


ii31 : end
../../Macaulay2/m2/option.m2:17:8:(1):[21]: --entering debugger (type help to see debugger commands)
../../Macaulay2/m2/option.m2:17:8-19:34: --source code:
       uncurry(f, override (opts,args))
       )
  )

ii32 : end
../../Macaulay2/m2/methods.m2:80:40:(1):[19]: --entering debugger (type help to see debugger commands)
../../Macaulay2/m2/methods.m2:80:40-80:51: --source code:
    if (f := lookup key) =!= null then dispatcher f else error noMethod(M, args, outputs))

ii33 : end
../../Macaulay2/m2/methods.m2:117:35:(1):[18]: --entering debugger (type help to see debugger commands)
../../Macaulay2/m2/methods.m2:117:35-117:146: --source code:
        binaryLookup := (x, y) -> binaryCaller'(methodFunction, (methodFunction, dispatchBy x, dispatchBy y), (x, y), outputs, dispatcher(o, (x, y)));

ii34 : end
../../Macaulay2/m2/methods.m2:72:40:(1):[17]: --entering debugger (type help to see debugger commands)
../../Macaulay2/m2/methods.m2:72:40-72:45: --source code:
foldL = (f, x, L) -> (scan(L, y -> x = f(x, y)); x)

ii35 : end
../../Macaulay2/m2/methods.m2:72:23:(1):[16]: --entering debugger (type help to see debugger commands)
../../Macaulay2/m2/methods.m2:72:23-72:45: --source code:
foldL = (f, x, L) -> (scan(L, y -> x = f(x, y)); x)

ii36 : end
../../Macaulay2/m2/methods.m2:118:9:(1):[15]: --entering debugger (type help to see debugger commands)
../../Macaulay2/m2/methods.m2:118:9-118:48: --source code:
        foldL(binaryLookup, args#0, drop(args, 1)));

ii37 : end
../../Macaulay2/m2/option.m2:40:8:(1):[14]: --entering debugger (type help to see debugger commands)
../../Macaulay2/m2/option.m2:40:8-42:30: --source code:
       uncurry(f, override (,args))
       )
  )

Admittedly the addition of layers above, particularly foldL is my own doing, and it was worth the speed improvement, but the plan has always been to eventually move it to the interpreter.

It would be great if some of these were either moved to the interpreter so that they would not be considered layers for the purposes of top-level debugging, or perhaps if there was an errorDepth displayed errors everywhere in Core but somehow exclude those involving methods and options.

related: #1928

mahrud avatar Aug 17 '22 20:08 mahrud

Similarly, an error like this:

../../Macaulay2/m2/debugging.m2:23:6:(1):[7]: error: expected all degrees to have length 1
../../Macaulay2/m2/debugging.m2:23:6:(1):[7]: --entering debugger (type help to see debugger commands)
../../Macaulay2/m2/debugging.m2:23:6-23:27: --source code:
     olderror processArgs args)

mahrud avatar Aug 18 '22 04:08 mahrud

This is still bugging me to no end:

ii38 : end
../m2/option.m2:40:8:(1):[36]: --entering debugger (type help to see debugger commands)
../m2/option.m2:40:7-40:29: --source code:
       uncurry(f, override (,args))
       )
  )

ii39 : end
../m2/methods.m2:154:80:(1):[35]: --entering debugger (type help to see debugger commands)
../m2/methods.m2:154:79-154:101: --source code:
     methodFunction := new MethodFunctionWithOptions from (opts >> o -> arg -> innerMethodFunction(o,arg));

ii40 : end
../m2/option.m2:40:8:(1):[34]: --entering debugger (type help to see debugger commands)
../m2/option.m2:40:7-40:29: --source code:
       uncurry(f, override (,args))
       )
  )

I don't quite understand how errorDepth works, but can we move this stuff deeper than the rest of Core?

mahrud avatar May 11 '24 16:05 mahrud