-
Notifications
You must be signed in to change notification settings - Fork 559
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
deparse doesn't handle classes #22777
Comments
Indeed so |
I don't really have any good thoughts on how to properly tackle this one. In the small scope, I can easily just get Deparse to handle an But in that situation it will just emit a named Ultimately I don't think Deparse is really set up to handle methods in classes. |
I have started to address this in #22790, but it only opens more questions that start a long and awkward slope. With that fix in place, the following output would be produced:
As you can see, no more complaints about unrecognised OK, so maybe the solution is to emit a Furthermore, this body isn't really usable because we've forgotten the definition of Any of these questions probably can be answered, but only by introducing a lot more awkward memories of what the original declaration syntax was, purely for the purpose of deparse. I don't know to what extent such a thing is justifiable. |
I see two main uses for Deparse: So while deparsing a class isn't so useful for the first, it's more useful for the second. As to :reader/:writer, I could see those simply deparsing the synthesized methods. Of course, to deparse the classes themselves, I expect B itself will need to be extended and those extensions might be useful elsewhere, like for meta.pm. I don't think any of this is urgent. It does bring up a possible flaw in the PPC process - do we try to resolve how some feature interacts with existing perl mechanisms, including magic, overloading, Data::Dumper, Storable, B::Deparse, Safe, eval (should failing to load a class allow a second attempt? #22374), quoting/subparsing and I'm sure I missed some. Right now that's left to the implementer. |
Module:
Trying to deparse a method of a class produces a message and incorrect code:
fields are also not deparsed:
Steps to Reproduce
See above.
Expected behavior
Deparse handles the OP_METHSTART and emits the field declarations.
Perl configuration
The text was updated successfully, but these errors were encountered: