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

Playground breakpoints: removal of last breakpoint leads to spurious "Run" action #1434

Open
martin-henz opened this issue Aug 5, 2020 · 5 comments
Labels
Bug Something isn't working minor Less important than important, but more than nice-to-have

Comments

@martin-henz
Copy link
Member

Here is the sequence. Notice the missing 4 in the last screen shot: Removing the last breakpoint triggered a "Run".

Screenshot 2020-08-05 at 11 40 18 AM

Screenshot 2020-08-05 at 11 40 26 AM

Screenshot 2020-08-05 at 11 40 32 AM

Screenshot 2020-08-05 at 11 40 49 AM

@martin-henz martin-henz added Bug Something isn't working minor Less important than important, but more than nice-to-have labels Aug 5, 2020
@martin-henz
Copy link
Member Author

This bug is still there. Just tried. Here is the program:
https://share.sourceacademy.nus.edu.sg/1ijs1

@martin-henz
Copy link
Member Author

This bug is still there.

https://share.sourceacademy.nus.edu.sg/5ya5k

The bug shows up in Source §3 but also in Source §1.

@ianyong ianyong assigned ianyong and unassigned podocarp and ianyong Feb 15, 2023
@ianyong
Copy link
Member

ianyong commented Feb 15, 2023

When the number of breakpoints goes from 1 to 0, line 763 is run which clears the REPL output:

const handleEditorUpdateBreakpoints = React.useCallback(
(breakpoints: string[]) => {
// get rid of holes in array
const numberOfBreakpoints = breakpoints.filter(arrayItem => !!arrayItem).length;
if (numberOfBreakpoints > 0) {
setHasBreakpoints(true);
if (propsRef.current.playgroundSourceChapter <= 2) {
/**
* There are breakpoints set on Source Chapter 2, so we set the
* Redux state for the editor to evaluate to the substituter
*/
propsRef.current.handleUsingSubst(true);
}
}
if (numberOfBreakpoints === 0) {
setHasBreakpoints(false);
if (selectedTab !== SideContentType.substVisualizer) {
propsRef.current.handleReplOutputClear();
propsRef.current.handleUsingSubst(false);
}
}
propsRef.current.handleEditorUpdateBreakpoints(breakpoints);
},
[selectedTab]
);

The reason this is done is because playground.debuggerContext.result.value is an array of objects used by the stepper (at least in Source 1) when the breakpoint is set:
image

Whereas without breakpoints, the playground.debuggerContext.result.value is an actual value that the REPL can display:
image

As such, we are forced to clear the REPL output because if the stepper's playground.debuggerContext.result.value is parsed by the normal REPL, the frontend crashes. @martin-henz It would seem that playground.debuggerContext.result.value is being used for 2 different purposes, and should be refactored into separate variables if we want to fix this bug.

@martin-henz
Copy link
Member Author

The stepper's use of breakpoints is quite lame right now: It switches to the stepper when a breakpoint is set, but it doesn't do anything with the breakpoints. It seems like the use of breakpoints by stepper wasn't well designed. Would it be a lot of trouble removing breakpoints from the stepper entirely? The loss would be minimal. Then, once we have a clear idea how to make use of breakpoints in the stepper, we can revisit this, hopefully with a better solution.

@ianyong
Copy link
Member

ianyong commented Feb 17, 2023

The stepper's use of breakpoints is quite lame right now: It switches to the stepper when a breakpoint is set, but it doesn't do anything with the breakpoints. It seems like the use of breakpoints by stepper wasn't well designed. Would it be a lot of trouble removing breakpoints from the stepper entirely? The loss would be minimal. Then, once we have a clear idea how to make use of breakpoints in the stepper, we can revisit this, hopefully with a better solution.

It seems that the refactoring might not be as simple as removing breakpoints from the stepper entirely since the debuggerContext.result.value is used by the stepper. In fact, the current design has led to previous bugs such as the one fixed in #2305. There is an issue #2306 that is tracking the same refactoring that is necessary to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working minor Less important than important, but more than nice-to-have
Projects
None yet
Development

No branches or pull requests

3 participants