Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

sanjana
Copy link
Contributor

@sanjana sanjana commented Oct 12, 2022

Purpose

$title

Fixes #36831

Approach

Samples

Remarks

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@sanjana sanjana added Team/CompilerFETools Semantic API, Formatter, Shell Area/SemanticAPI Semantic API Related Issues #Compiler labels Oct 12, 2022
@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

Base: 76.64% // Head: 76.65% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (2e18924) compared to base (132861c).
Patch coverage: 66.66% of modified lines in pull request are covered.

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     
Impacted Files Coverage Δ
...iler/semantics/analyzer/ConstantValueResolver.java 84.61% <66.66%> (-0.12%) ⬇️
...a/runtime/internal/scheduling/RuntimeRegistry.java 62.26% <0.00%> (-20.76%) ⬇️
...internal/repositories/RemotePackageRepository.java 79.59% <0.00%> (-1.54%) ⬇️
...a/io/ballerina/converters/JsonToRecordRequest.java 54.54% <0.00%> (-1.02%) ⬇️
...ballerinalang/central/client/CentralAPIClient.java 47.92% <0.00%> (-0.40%) ⬇️
...rinalang/compiler/semantics/model/SymbolTable.java 96.65% <0.00%> (-0.15%) ⬇️
...io/ballerina/converters/JsonToRecordConverter.java 83.41% <0.00%> (-0.09%) ⬇️
...io/ballerina/semver/checker/diff/NodeDiffImpl.java 71.42% <0.00%> (ø)
...erina/runtime/internal/BallerinaXmlSerializer.java 81.10% <0.00%> (+0.08%) ⬆️
...erina/converters/JsonToRecordConverterService.java 95.83% <0.00%> (+0.18%) ⬆️
... and 21 more

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -358,3 +358,6 @@ function fooFn() returns future<int> {
function barFn() returns int {
return 10;
}

const int A = 10;
const int B = 20 + 30;
Copy link
Contributor

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

Copy link
Member

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.

Copy link
Contributor Author

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.

@github-actions
Copy link

github-actions bot commented Nov 2, 2022

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Nov 2, 2022
@gimantha gimantha removed the Stale label Nov 3, 2022
@github-actions
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Nov 18, 2022
@gimantha gimantha removed the Stale label Nov 18, 2022
@github-actions
Copy link

github-actions bot commented Dec 4, 2022

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Dec 4, 2022
@gimantha gimantha removed the Stale label Dec 4, 2022
@github-actions
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Dec 20, 2022
@gimantha gimantha removed the Stale label Dec 20, 2022
@github-actions
Copy link

github-actions bot commented Jan 4, 2023

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Jan 4, 2023
@gimantha gimantha removed the Stale label Jan 5, 2023
@github-actions
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Jan 20, 2023
@gimantha gimantha removed the Stale label Jan 23, 2023
@github-actions
Copy link

github-actions bot commented Feb 7, 2023

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Feb 7, 2023
@sanjana sanjana removed the Stale label Feb 8, 2023
@github-actions
Copy link

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

@github-actions github-actions bot added the Stale label Feb 24, 2023
@github-actions
Copy link

Closed PR due to inactivity for more than 18 days.

@github-actions github-actions bot closed this Feb 28, 2023
@sanjana sanjana removed the Stale label Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/SemanticAPI Semantic API Related Issues #Compiler Team/CompilerFETools Semantic API, Formatter, Shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistency in the behaviour of typeOf API
3 participants