-
Notifications
You must be signed in to change notification settings - Fork 847
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
Optional Chaining Operator ?. #1593
base: master
Are you sure you want to change the base?
Conversation
.?
.?
.?
.?
Please uncomment |
… language/expressions/optional-chaining section in test262 and reworking the solution to pass them, including the necessity to clone ASTNode to avoid problems introduced due to structural sharing betweek left and right of left.?rigth.
That's done and the results are part of the last commit. Sadly troubleshooting through those tests has exposed a problem with this approach to implementing this operator. The core idea was to replace optional chaining operator expression tree with a conditional expression like below
but this means that we're rewriting the tree into something like this
and crucially the actual ASTNode for So, I don't think this works without cloning ASTNodes, which turns out is not that easy as one could expect. I ended up finding a hacky way to do this ( I don't even want to think about the performance hit.. 🙄 ) but I really hope someone knows a better way.. |
Thnx for trying! Not an expert at all in this area, but maybe an approach like was taken in the exponential operator implementation could help That implementation implements it's logic for interpreted and compiled mode in two different locations (see separate commits for each area). What I'm suggesting is instead of rewriting the ast tree, maybe instead implement the explicit logic for dealing with this operator again: no expert, so maybe a complete bogus suggestion 🤪 |
…tional method call for `?.` operator
Following your advice, I've added 3 new bytecodes to handle in the Interpreter / Compiler :
To handle the optional property get ( |
Optional chaining operator by transforming into conditional expression in IRFactory, similar #1591