Macaulay2 / Macaulay2/M2

Spurious layers when debugging

Open
#2,568 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Interpreter
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

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:
```m2

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the debugger behavior shown in m2/option.m2 and m2/methods.m2, then trace how method calls, options, and foldL become debugger layers. Compare the possible interpreter-level and errorDepth approaches; done means the agreed behavior avoids irrelevant repeated stops while preserving useful debugging information.

Written by the indexing model from the issue text.

Assessment

Domain
devtools
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.