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

Fix BFields of generated immutable BRecords not being marked as SymbolFlags.READONLY #42521

Conversation

Thushara-Piyasekara
Copy link
Contributor

@Thushara-Piyasekara Thushara-Piyasekara commented Apr 9, 2024

Purpose

Fixes #42520

Approach

After a discussion with @heshanpadmasiri, it was apparent the InherentTypeViolation error for BFields of readonly BRecords were not getting triggered. This was due to the mutable BRecord generation not inheriting the readonly flag to the generated BFields.

After refactoring the logic to make the BFields also inherit the readonly flag, both cases mentioned in #42520 triggered the same error.

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

  • 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

@Thushara-Piyasekara Thushara-Piyasekara marked this pull request as ready for review April 9, 2024 12:53
@Thushara-Piyasekara Thushara-Piyasekara marked this pull request as draft April 10, 2024 01:39
@Thushara-Piyasekara Thushara-Piyasekara force-pushed the fix-error-code-inconsistency branch 2 times, most recently from 98020f7 to a96071c Compare April 10, 2024 04:45
@Thushara-Piyasekara Thushara-Piyasekara marked this pull request as ready for review April 10, 2024 05:25
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 Apr 26, 2024
@nipunayf nipunayf removed the Stale label Apr 27, 2024
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 May 22, 2024
@nipunayf nipunayf removed the Stale label May 23, 2024
Copy link

github-actions bot commented Jun 7, 2024

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 Jun 7, 2024
Copy link

Closed PR due to inactivity for more than 18 days.

@github-actions github-actions bot closed this Jun 12, 2024
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.52%. Comparing base (a72fc91) to head (f4b21aa).
Report is 266 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #42521      +/-   ##
============================================
+ Coverage     77.35%   77.52%   +0.17%     
- Complexity    58588    58718     +130     
============================================
  Files          3460     3447      -13     
  Lines        220086   219720     -366     
  Branches      28909    28938      +29     
============================================
+ Hits         170237   170329      +92     
+ Misses        40432    39970     -462     
- Partials       9417     9421       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 Stale and removed Stale labels Jul 17, 2024
Copy link

github-actions bot commented Aug 5, 2024

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 Aug 5, 2024
@nipunayf nipunayf removed the Stale label Aug 6, 2024
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 Stale and removed Stale labels Aug 22, 2024
Copy link

github-actions bot commented Sep 8, 2024

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.

@gimantha gimantha marked this pull request as draft September 10, 2024 03:34
@SasinduDilshara SasinduDilshara marked this pull request as ready for review September 10, 2024 05:45
Comment on lines +172 to 175
expectedExceptionsMessageRegExp = "error: \\{ballerina/lang.map}InherentTypeViolation \\{\"message\":" +
"\"cannot update 'readonly' field 'name' in record of type 'Details & readonly'\".*")
public void testCreateDetails() {
BRunUtil.invoke(result, "testCreateDetails");
Copy link
Member

Choose a reason for hiding this comment

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

If the entire record is immutable, the former error is better?

Copy link
Contributor

@SasinduDilshara SasinduDilshara Oct 4, 2024

Choose a reason for hiding this comment

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

Imo, the new message is more meaningful.
And also the new error message is the one we normally get, when we updating a immuatable value

@gimantha gimantha merged commit afc5db7 into ballerina-platform:master Oct 4, 2024
18 checks passed
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.

[Bug]: Inconsistent runtime error messages when trying to modify a readonly record field
7 participants