Skip to content

Add support for if expressions#446

Open
Bazooper-blip wants to merge 1 commit into
integrated-application-development:masterfrom
Bazooper-blip:claude/pr-440-upmerge-adjust-L8U0P
Open

Add support for if expressions#446
Bazooper-blip wants to merge 1 commit into
integrated-application-development:masterfrom
Bazooper-blip:claude/pr-440-upmerge-adjust-L8U0P

Conversation

@Bazooper-blip
Copy link
Copy Markdown

Resolves #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.

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>
Copy link
Copy Markdown
Collaborator

@cirras cirras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you closed #440 and opened a new PR. If it's because there was a merge commit in that PR, that could have easily been cleaned up by rewriting the PR branch. 🤔

Copy link
Copy Markdown
Collaborator

@cirras cirras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolves #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.

This whole commit message body looks like an AI-generated summary of implementation minutia and is not useful.

}
}

public Type resolve(IfExpressionNode expression) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the third time, this implementation is simply incorrect. I won't be able to accept this PR without accurate type resolution.

Please read the Embarcadero documentation.

... and test your assumptions against the Delphi 13 compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support if expressions

2 participants