Add support for if expressions#446
Conversation
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.
Resolves integrated-application-development#407. Delphi 13 introduces an `if ... then ... else ...` expression. Parse it, model the branches as mutually-exclusive paths in the control flow graph, and resolve its type as the least upper bound of the branch types, as determined by the Delphi compiler. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fa3c967 to
60424f1
Compare
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.