-
Notifications
You must be signed in to change notification settings - Fork 735
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
Preserve the determined type of constant value expressions #38183
Conversation
Codecov ReportBase: 76.64% // Head: 76.65% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #38183 +/- ##
============================================
+ Coverage 76.64% 76.65% +0.01%
- Complexity 53050 53056 +6
============================================
Files 3354 3354
Lines 199180 199195 +15
Branches 25841 25842 +1
============================================
+ Hits 152655 152693 +38
+ Misses 37849 37839 -10
+ Partials 8676 8663 -13
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -358,3 +358,6 @@ function fooFn() returns future<int> { | |||
function barFn() returns int { | |||
return 10; | |||
} | |||
|
|||
const int A = 10; | |||
const int B = 20 + 30; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjana I have a doubt on the original issue (#36831) though.
Say I want to extract the constant. The extracted constant can be either the exact singleton value 30
or it can have the wider basic type node int
. As of the current implementation, it only allows int
. But @SandaruJayawardana is doing a complete revamp for constant expressions and both have to be allowed. What should be the user experience for this one?
const 30 A = 10 + 20; // valid
const int A = 10 + 20; // also valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is with the expression, right?
I think the behaviour should be consistent for both RHS expressions in
const int A = 10;
const int B = 20 + 30;
If the type of 10
is int
, it should be the same for 20 + 30
also. But if the type for 20 + 30
is singleton 50
, the type for 10
should also be singleton 10
. Feels like the singleton approach is more accurate, but since this applies to all literals, may result in a lot of new types being created.
For example, even with int i = 10;
, the type of 10
will then be the singleton.
I think we need to discuss this and come to a conclusion and then fix across the compiler for all literals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be holding this PR until the discussion initiated at #38250 is finalized.
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
Closed PR due to inactivity for more than 18 days. |
Purpose
Fixes #36831
Approach
Samples
Remarks
Check List