M2 icon indicating copy to clipboard operation
M2 copied to clipboard

Incorrect code location for functions defined in standard input

Open d-torrance opened this issue 1 year ago • 3 comments

Since #3403:

i1 : f = x -> x^2

o1 = f

o1 : FunctionClosure

i2 : code f

o2 = stdio:1:6-1:11: --source code:
     -- This is the beginning of your Macaulay2 log stored at /home/profzoom/.Macaulay2/history.m2

I suppose the solution would be to keep track of how long the history is when we start M2 and add that to the line number when finding the code.

d-torrance avatar Aug 18 '24 13:08 d-torrance

Ah yes I should have noticed this from the getHistory lines in code.m2.

mahrud avatar Aug 18 '24 14:08 mahrud

This is actually more complicated than I expected. I added a call to where_history in this commit, but:

  1. it seems to return zero if it's called before the first prompt, even if it's after readHistory apparently!
  2. it seems to be off by an inconsistent number (up to 4 even) from the right number to get code working in your example.

I'm not sure if I have time to debug this. We can disable history if this is too complicated to resolve.

mahrud avatar Aug 18 '24 20:08 mahrud

I think I figured it out -- see #3416.

d-torrance avatar Aug 18 '24 22:08 d-torrance

Closed by #3416

d-torrance avatar Sep 13 '24 17:09 d-torrance