-
Notifications
You must be signed in to change notification settings - Fork 134
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
Consideration of PM_INDEX_WRITE_NODE #2937
Comments
We could potentially consider another node for this, but that's what the Would that flag work for you, or do you think we should try a new node? |
@kddnewton Thanks for the reply (and thank you for your all-time effort!)
Yes, technically, I can compile it correctly by looking at the flags. My personal opinion about this case: For me, a tricky part is knowing whether I need to look at the flags carefully all the time. Well, I don't have a strong thought. It might be a good idea to hear many people's opinions on this. How about making it an agenda for the Ruby core team? |
Making the return value the same as the RHS is specifically what Regarding whether to care or not about flags I would think for a compiler one should consider all flags on a node, most are necessary or useful for compilation, a few can be ignored. Maybe we could document flags which are expected to have no effect on compilation, OTOH it seems few of them and relatively clear already. |
@hasumikin — I can definitely see your point. We do have quite a few different node types, so I can see why you would want another one here. My reasoning for putting it into one node: one of the biggest complaints with the existing CRuby AST was that there were too many different call node types. (QCall, VCall, FCall, Command, CommandCall, Call, etc.) It made it very difficult for consumers of the AST on the static analysis side to know that they had covered all call sites. While we have already deviated from that a bit (because of control-flow calls which could represent many method calls and target calls which have different field sets) we've mostly tried to isolate all of the method calls into one node to make it easier on those consumers. The other piece of this is that while making this into a new node will solve your problem for For these reasons, I'd like to keep it in the same node for now. But thank you very much for the thoughtful issue! |
As of 0.30.0,
Prism.parse("a[0] = 1")
andPrism.parse("a.[]=(0, 1)")
will generate almost the same AST (I know we can distinguish them by the flags of CallNode though) like follows:The point is that
a[0] = 1
does not generate an assignment node, a kind of PM_somehow_WRITE_NODE, despite being an assignment expression.Matz says it is possibly a bug:
mruby/mruby#6303 (comment)
I guess, you may need a thing like PM_INDEX_WRITE_NODE for
a[idx] = object
.What do you say?
The text was updated successfully, but these errors were encountered: