Add support for if expressions - #450
Conversation
fourls
left a comment
There was a problem hiding this comment.
Looks good for the most part! A couple of minor comments.
|
Addressed review feedback and, in the process, discovered the resolver was handling array constructors incorrectly. |
fourls
left a comment
There was a problem hiding this comment.
Looks really good! The array element type inference being wrong is a bit of a surprise - I guess it's a fairly niche case.
On top of the comments below, could you also rebase on master to get the Java 25 compatibility fixes?
fourls
left a comment
There was a problem hiding this comment.
Looks good! This will go a long way to unblocking Delphi 13 support.
As always, I'm sure there's a bunch of bizarre edge case behavioural quirks that we've missed and will have to slowly discover over time 😅
This PR implements
ifexpressions.Embarcadero Documentation
The language feature is documented by Embarcadero here.
They even kindly provided a table of operand type combinations with the corresponding result type.
Reality
Unfortunately, the documented operand/result type combinations are inaccurate or incomplete in various ways.
Below is what Delphi 13 actually does.
[...]constructor[...]constructorarray of Treference totype, if they have the same signatureset of Byteorset of AnsiChar[...]constructor[...]constructor[...]constructorWorking out the actual rules required a lot of painful testing against the Delphi 13 compiler, but I think this is pretty accurate now.
It definitely isn't a "least upper bound" as commonly understood, or as documented:
UInt64Fun Facts
if b then [] else DynArraycrashes the 64-bit compiler with an internal error (F2084).