Skip to content

Fix #10107: Improve inline if constant condition detraction and reporting #10114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2020

Conversation

nicolasstucki
Copy link
Contributor

Showing the reduced condition is much more useful than showing the original condition.

@nicolasstucki nicolasstucki changed the title Improve error message for inline if Improve inline if constant condition detraction and reporting Oct 28, 2020
@nicolasstucki nicolasstucki linked an issue Oct 28, 2020 that may be closed by this pull request
@nicolasstucki nicolasstucki changed the title Improve inline if constant condition detraction and reporting Fix #10107: Improve inline if constant condition detraction and reporting Oct 28, 2020
@nicolasstucki nicolasstucki requested a review from odersky October 28, 2020 17:37
@nicolasstucki nicolasstucki marked this pull request as ready for review October 28, 2020 17:37
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

errorTree(tree, em"""cannot reduce inline if
| its condition ${tree.cond}
| is not a constant value""")
errorTree(tree, em"""Cannot reduce `inline if` with non constant value.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the old error message is clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue with the previous message is that the condition is printed in the middle of the message. That condition may be long or have several lines. Ideally we should have a message where the tree is printed last.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cannot reduce `inline if` because its condition is not a constant value:
$cond1

I keep meaning to see that Ralph Fiennes movie, "The Constant Gardener."

If we could use that title for a narrative about compilation, then we'd have the same problem as that other Fiennes movie, "The English Patient," whether to emphasize the adjective or the noun.

The suggested edit avoids "non constant" --> "non-constant" --> "inconstant" discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used "Cannot reduce `inline if` because its condition is not a constant value: $cond".

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I see the reasoning now.

@odersky odersky assigned nicolasstucki and unassigned odersky Oct 29, 2020
Showing the reduced condition is much more useful than showing the original condition.
@odersky odersky merged commit 4cf3bf0 into scala:master Oct 30, 2020
@odersky odersky deleted the fix-#10107 branch October 30, 2020 16:45
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

inline if error suggests it expects a literal expression
4 participants