Skip to content

Allow implicit cast to non-const in binary exprs. #2430

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 3 commits into from
May 19, 2025

Conversation

orpuente-MS
Copy link
Contributor

@orpuente-MS orpuente-MS commented May 19, 2025

This PR fixes an issue in casting where the following code was treated as an error.

int x = 5;
int y = 2 * x;

The issue was that 2 is a constant, and the casting system wasn't allowing x, of type int, which isn't a constant to be cast to the type of 2, which is const int. The fix consists in allowing the type of the binary expression as a whole to be demoted to a non-const type.

@orpuente-MS orpuente-MS enabled auto-merge May 19, 2025 21:30
@orpuente-MS orpuente-MS added this pull request to the merge queue May 19, 2025
Merged via the queue into main with commit 5ce894c May 19, 2025
18 checks passed
@orpuente-MS orpuente-MS deleted the oscarpuente/fix-casting-issue branch May 19, 2025 22:13
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.

2 participants