Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect code location for functions defined in standard input #3415

Closed
d-torrance opened this issue Aug 18, 2024 · 4 comments
Closed

Incorrect code location for functions defined in standard input #3415

d-torrance opened this issue Aug 18, 2024 · 4 comments

Comments

@d-torrance
Copy link
Member

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.

@mahrud
Copy link
Member

mahrud commented Aug 18, 2024

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

@mahrud
Copy link
Member

mahrud commented Aug 18, 2024

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 mahrud added this to the version 1.24.11 milestone Aug 18, 2024
d-torrance added a commit to d-torrance/M2 that referenced this issue Aug 18, 2024
When reading the history from a file, we need to add the number of
lines loaded from previous sessions when calling getHistory to get the
correct lines of code.

Closes: Macaulay2#3415
@d-torrance
Copy link
Member Author

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

d-torrance added a commit that referenced this issue Aug 21, 2024
When reading the history from a file, we need to add the number of
lines loaded from previous sessions when calling getHistory to get the
correct lines of code.

Closes: #3415
Devlin-Mallory pushed a commit to Devlin-Mallory/M2 that referenced this issue Aug 30, 2024
When reading the history from a file, we need to add the number of
lines loaded from previous sessions when calling getHistory to get the
correct lines of code.

Closes: Macaulay2#3415
@d-torrance
Copy link
Member Author

Closed by #3416

mgacummings pushed a commit to mgacummings/M2 that referenced this issue Oct 19, 2024
When reading the history from a file, we need to add the number of
lines loaded from previous sessions when calling getHistory to get the
correct lines of code.

Closes: Macaulay2#3415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants