Skip to content

Adjust assignment line number for match #6083

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

Closed
wants to merge 1 commit into from

Conversation

iluuu1994
Copy link
Member

Otherwise the assignment will have the same number as the default arm which will 1. mis-trigger a breakpoint and 2. mark the line as covered even when it isn't.

/cc @derickr

@nikic The line number does not need to be reset, right? Tests are passing but I don't think line numbers are extensively tested.

Otherwise the assignment will have the same number as the default arm
which will 1. mis-trigger a breakpoint and 2. mark the line as covered
even when it isn't.
@derickr
Copy link
Member

derickr commented Sep 6, 2020

This currently breaks a whole bunch of tests for me in Xdebug now, will investigate why over the next few days.

@iluuu1994
Copy link
Member Author

@derickr Ok, let me know if those changes make sense or if this needs more tweaking.

@iluuu1994
Copy link
Member Author

@derickr Btw can you also try this and see if the output of your tests is any different?

uint32_t tmp = CG(zend_lineno);
CG(zend_lineno) = zend_ast_get_lineno(var_ast);
zend_emit_op_tmp(result, ZEND_ASSIGN, &var_node, &expr_node);
CG(zend_lineno) = tmp;

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but let's wait for Derick.


$foo = match (0) {
0 => 'foo',
default => 'bar',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default => 'bar',
default => 'bar', // breakpoint #0

Maybe, so one doesn't have to count lines.

@derickr
Copy link
Member

derickr commented Sep 7, 2020

Yes, this looks good now I've checked my test cases. The funny thing is that these test cases test for a feature in Xdebug that "resolve" lines where people (IDEs) set breakpoints, to the nearest line that has an actual EXT_STMT on it, but finding an earlier or later line. They (almost all) test:

$a = array(
    'a',
);

Before this patch, the EXT_STMT and ASSIGN where on the 'a', line, so Xdebug resolved a breakpoint set on the line with $a = array( to the one below (with the EXT_STMT). Which your patch, the ASSIGN and EXT_STMT correctly show up at the user-expected '$a = array(` line, but that of course thwarts my test that tested the resolving!

In any case, this now works as expected, so I'm just going to have to come up with new tests :-/.

@php-pulls php-pulls closed this in 8a49310 Sep 7, 2020
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

Successfully merging this pull request may close these issues.

3 participants