ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

Remove unnecessary casting for record field set

Open heshanpadmasiri opened this issue 1 year ago • 6 comments

Purpose

Remove unnecessary casting for record field set

Fixes #41876 Depends on #41998

Approach

Describe how you are implementing the solutions along with the design details.

Samples

Provide high-level details about the samples related to this feature.

Remarks

List any other known issues, related PRs, TODO items, or any other notes related to the PR.

Check List

  • [x] Read the Contributing Guide
  • [ ] Updated Change Log
  • [ ] Checked Tooling Support (#<Issue Number>)
  • [ ] Added necessary tests
    • [x] 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

heshanpadmasiri avatar Dec 22 '23 02:12 heshanpadmasiri

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 76.82%. Comparing base (09e0471) to head (6551fb8). Report is 162 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##             master   #41917       +/-   ##
=============================================
+ Coverage      0.00%   76.82%   +76.82%     
- Complexity        0    53968    +53968     
=============================================
  Files             9     2924     +2915     
  Lines            35   203890   +203855     
  Branches          0    26589    +26589     
=============================================
+ Hits              0   156631   +156631     
- Misses           35    38720    +38685     
- Partials          0     8539     +8539     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 22 '23 07:12 codecov[bot]

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[bot] avatar Feb 03 '24 19:02 github-actions[bot]

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[bot] avatar Feb 27 '24 19:02 github-actions[bot]

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[bot] avatar Mar 15 '24 19:03 github-actions[bot]

Still for following kind of scenarios we create the unnecessary cast

type R record {|
    int f;
|};

function foo() {
    R|R r = { f: 5 };
    r.f = 6;
}

chiranSachintha avatar Mar 19 '24 10:03 chiranSachintha

Still for following kind of scenarios we create the unnecessary cast

type R record {|
    int f;
|};

function foo() {
    R|R r = { f: 5 };
    r.f = 6;
}

I think this is a different issue from https://github.com/ballerina-platform/ballerina-lang/issues/41876 since we are not casting the value being assigned (ie 6) but R. And if I am not mistaken we do this whenever we refer to r irrespective of whether we are dealing with an assignment or not. May I create a separate issue for this because I suspect this has do with current type system not being able to reduce R|R to R (I expect this to fix itself with the semtype introduction)

heshanpadmasiri avatar Mar 20 '24 03:03 heshanpadmasiri

@heshanpadmasiri Ubuntu and windows build are failing. Please check

chiranSachintha avatar Apr 03 '24 04:04 chiranSachintha