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

[Bug]: Type reference type information is not available for record values #43633

Open
rdulmina opened this issue Nov 21, 2024 · 1 comment
Open
Labels
Area/BIR Compiler BIR related issues #Compiler Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation

Comments

@rdulmina
Copy link
Contributor

Description

Consider the below sample

type Foo2 record {|
    string s;
    *RefType;
    int i;
    *ClosedRefType;
|};

function testRefTypes() returns Foo2 {
    Foo2 f = {s:"qwerty", i:10, rx:xml `<book>Count of Monte Cristo</book>`, rp:new("John Doe"), crp:new("Jane Doe"), crx:xml `<book>Count of Monte Cristo</book>`};
    json j = {name: "apple", color: "red", price: 40};
    Address adr = {city:"Colombo", country:"Sri Lanka"};

    f.rj = j;
    f.ra = adr;
    f.crj = j;
    f.cra = adr;

    return f;
}

When we get the type of the return value, it is BRecordType. This should Ideally be BTypeReferenceType

Screenshot 2024-11-21 at 11 18 03

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@rdulmina rdulmina self-assigned this Nov 21, 2024
@rdulmina rdulmina added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Reason/EngineeringMistake The issue occurred due to a mistake made in the past. labels Nov 21, 2024
@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Nov 21, 2024
@rdulmina rdulmina added Area/BIR Compiler BIR related issues #Compiler and removed needTriage The issue has to be inspected and labeled manually labels Nov 21, 2024
@MaryamZi
Copy link
Member

MaryamZi commented Nov 21, 2024

I believe we always set a mapping type (map type or record type) to mapping values.

This is somewhat similar to what we had at compile-time before your changes to persist the type reference type in the frontend even with expressions.

This may not be incorrect either. Note that in the spec, the type-reference type-descriptor is only for an alias - see https://ballerina.io/spec/lang/master/#type-reference. So what we get with typeof (which is effectively what you're doing here), being a record seems okay.

rdulmina added a commit that referenced this issue Nov 21, 2024
@rdulmina rdulmina removed their assignment Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/BIR Compiler BIR related issues #Compiler Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

3 participants