[flow analysis] Clean up promoted types ordering and use of ::#4369
Conversation
The `promotedTypes` list in a `VariableModel` is now consistently ordered from least promoted type to most promoted type, matching the list used in the implementation. Also, the use of `X::Y` to refer to a stack is adjusted so that `Y` refers to the top of the stack and `X` refers to the rest of the stack. This is consistent with the way some stacks are represented in the flow analysis implementation (as a list where pushing and popping happens at the end of the list). Fixes dart-lang#4367.
eernstg
left a comment
There was a problem hiding this comment.
LGTM, considering that the most important thing is to be consistent.
I would mention, though, that h::t almost inevitably means a list where h is an element which is at the head (first) in the list, and t is the tail (the rest) of the list, and t::h is going to look really weird to a functional programmer.
Perhaps use another notation? One notation that would look normal for functional programmers could be t ++ [h], where ++ is a list concatenation operator. That would allow us to connect to actual Dart code like tail + [head], and it would also handle tail ++ [n1, n0] in a way which is reasonably concise.
That's a good point. I've switched to a notation that resembles Dart list syntax: I'm going to go ahead and land the change in this form based on your previous lgtm. If you have concerns, let me know and I can always do a follow up PR. |
The
promotedTypeslist in aVariableModelis now consistently ordered from least promoted type to most promoted type, matching the list used in the implementation.Also, the use of
top::restto refer to a stack is changed to[...rest, top]. This is consistent with the way some stacks are represented in the flow analysis implementation (as a list where pushing and popping happens at the end of the list).Fixes #4367.