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

[2201.8.x] Fix value conversion error for inline record creation with special characters #41641

Conversation

HindujaB
Copy link
Contributor

@HindujaB HindujaB commented Nov 3, 2023

Purpose

$subject

Fixes #41633

Approach

As we use the decoded identifiers in the value conversions, the generated record value creators should have the same representation in the switch cases. This PR fixes it by using the Utils.unescapeBallerina() API.

Samples

import ballerina/io;

public type Copybook record {
    DFHCOMMAREA DFHCOMMAREA?;
};

public type DFHCOMMAREA record {
    record {
        string MI\-HDR\-VERSION?;
        string MI\-HDR\-MSGID?;
        string MI\-HDR\-LOGGINGID?;
        record {
            string MI\-HDR\-REPLYQMGR?;
        }[2] MI\-HDR\-REPLYSTACK?;
    } BROKER\-MESSAGE\-AREA?;
};

public function main() returns error? {
    string s = string `{
    "DFHCOMMAREA": {
        "BROKER-MESSAGE-AREA": {
            "MI-HDR-VERSION": "2",
            "MI-HDR-MSGID":"3238763233323598798798712321187612",
            "MI-HDR-LOGGINGID": "Z5118761-Z"
        }
    }
    }`;
    json rec = checkpanic value:fromJsonString(s);
    map<json> mapJson = check rec.ensureType();
    Copybook dfhcommarea = check mapJson.cloneWithType();
    io:println(dfhcommarea.DFHCOMMAREA?.BROKER\-MESSAGE\-AREA);
}

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

Copy link

codecov bot commented Nov 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (13e4b90) 76.34% compared to head (4951240) 76.34%.
Report is 7 commits behind head on 2201.8.x.

Additional details and impacted files
@@             Coverage Diff             @@
##             2201.8.x   #41641   +/-   ##
===========================================
  Coverage       76.34%   76.34%           
- Complexity      52517    52518    +1     
===========================================
  Files            2881     2881           
  Lines          198585   198587    +2     
  Branches        25801    25802    +1     
===========================================
+ Hits           151610   151615    +5     
+ Misses          38618    38614    -4     
- Partials         8357     8358    +1     
Files Coverage Δ
...rinalang/compiler/bir/codegen/JvmDesugarPhase.java 95.13% <100.00%> (+0.04%) ⬆️

... and 5 files with indirect coverage changes

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

Copy link
Contributor

@gabilang gabilang left a comment

Choose a reason for hiding this comment

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

LGTM

@warunalakshitha warunalakshitha merged commit e7c65e6 into ballerina-platform:2201.8.x Nov 6, 2023
@DimuthuMadushan DimuthuMadushan added this to the 2201.8.3 milestone Nov 10, 2023
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.

4 participants