Add support for if expressions#446
Conversation
Resolves integrated-application-development#407. Introduces parsing, type resolution, and control-flow modelling of Delphi 13's conditional `if` operator (e.g. `X := if Foo then Bar else Baz`). The branches are modelled as mutually-exclusive paths in the CFG. The expression's type is the LUB of the then/else branch types: exact matches and unknown-side fallbacks are returned directly; if only one branch's type is assignable to the other, the more permissive one wins; if both are bidirectionally assignable, the wider one (higher conversion score) is chosen; for unrelated struct types, a shared ancestor in the parent chain is used; otherwise the result is the unknown type. Co-Authored-By: Claude <noreply@anthropic.com>
cirras
left a comment
There was a problem hiding this comment.
Resolves #407. Introduces parsing, type resolution, and control-flow
modelling of Delphi 13's conditionalifoperator
(e.g.X := if Foo then Bar else Baz). The branches are modelled as
mutually-exclusive paths in the CFG.The expression's type is the LUB of the then/else branch types:
exact matches and unknown-side fallbacks are returned directly; if
only one branch's type is assignable to the other, the more
permissive one wins; if both are bidirectionally assignable, the
wider one (higher conversion score) is chosen; for unrelated struct
types, a shared ancestor in the parent chain is used; otherwise
the result is the unknown type.
This whole commit message body looks like an AI-generated summary of implementation minutia and is not useful.
| } | ||
| } | ||
|
|
||
| public Type resolve(IfExpressionNode expression) { |
There was a problem hiding this comment.
For the third time, this implementation is simply incorrect. I won't be able to accept this PR without accurate type resolution.
Resolves #407. Introduces parsing, type resolution, and control-flow modelling of Delphi 13's conditional
ifoperator (e.g.X := if Foo then Bar else Baz). The branches are modelled as mutually-exclusive paths in the CFG.The expression's type is the LUB of the then/else branch types: exact matches and unknown-side fallbacks are returned directly; if only one branch's type is assignable to the other, the more permissive one wins; if both are bidirectionally assignable, the wider one (higher conversion score) is chosen; for unrelated struct types, a shared ancestor in the parent chain is used; otherwise the result is the unknown type.