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
Prepostfix boundary does not get properly cloned; missing a test? #189
Comments
|
does this go in t/parsing? :P |
|
My first instinct would be to put it in |
|
I'm currently putting it in the former, because it seems to make more sense. If you want it to be a separated file, I don't think it should be in |
|
Ah, obviously it wasn't going to be that easy. "Fixing" the bug by making the variable public gives: |
|
Confirmed locally. I added some debugging info. The numbers denote how Here's a normal run, without the change. The first six lines are from the bulitins (and should probably not happen through that code path, see #185). The last four lines are the test. Here's a run with the change. I haven't tried to analyze what goes wrong yet. Just posting these debug outputs first. I'll get back to you when I know more. |
This shouldn't be necessary, and by some alpha-renaming argument is basically a no-op. Still, in #189 we hit some strangeness where the expression parser seems to confuse prefix:<!> with postfix:<!>. Will investigate that further, of course. But this fixes it, short term.
|
I found the problem. Pushed a fix with 4423c0a. Try now. The debug output gets everything right, and so the problem is not found there. But looking at it put be on the right track: what if something in 007 gets Anyway, now your fix should apply well. I'll open a new issue for the |
Just discovered this in
OpScope.pm:The intent is clear: we want to clone the
$!prepostfix-boundaryattribute with the rest of the opscope. Of course.But private attributes aren't settable through the default
new, as demonstrated here:So
What test? Basically a recapitulation of the above demonstration, but in the context of the boundary between prefix and postfix ops. (This, by the way, is something I should write down somewhere. I see operators.md oddly has no mention of it. The commit that adds the attribute (and the bug), 6093795, doesn't mention the boundary at all.)
Ok, let's see.
Prefixes never compete for precedence on their own, because syntactically they get a natural nesting and inside-out evaluation order. But they can compete via a postfix, since prefixes and postfixes share a precedence space.
The statement block above is exactly so that an opscope cloning will happen and we will lose our prepostfix-boundary (aka "the bug"). Had we kept that boundary,
prefix:<$>would have been installed to the right of (=tighter than)prefix:<&>. But now it gets installed on its left, and the print statement demonstrates that.Phew! No wonder we didn't have a test for this!
In fact, we could exploit our tightest built-in prefix op for the same effect, with a bit less code:
...but this code is possibly coupled to the default built-ins, which might after all change in the future for good reasons. I think I like the longer test better.
Ok, that was a lot of talking. The task here is simple: add the test. See it fail. Make
$!prepostfix-boundarypublic, so that it doesn't get clobbered during a clone. See the test pass. So it's a test and a one-line fix.The text was updated successfully, but these errors were encountered: