Giter VIP home page Giter VIP logo

Comments (3)

MaryamZi avatar MaryamZi commented on May 24, 2024

Looping in @HindujaB, since this is an issue specific to configurable variables.

Is your expectation to get readonly and ReadOnlyRecord as constituent types? The current behaviour may be because ReadOnlyRecord is already readonly.

The spec requirements is

The static type of a variable declared as configurable is implicitly readonly: the type specified in the type-descriptor is intersected with readonly.

So IMO, we don't really have to create an intersection type that is readonly & ReadOnlyRecord for record1, which is effectively readonly & (readonly & record { string readOnlyValue; }).

Also note that even if you did get readonly and ReadOnlyRecord as constituent types, ReadOnlyRecord will be an intersection type where one of it's constituent types will be an anonymous record type. The behaviour won't be the same as for NormalRecord, since with

public type NormalRecord record {
    string normalValue;
};

the name NormalRecord is specified for the record, whereas with

public type ReadOnlyRecord readonly & record {
    string readOnlyValue;
};

the name is for the intersection type.

from ballerina-lang.

HindujaB avatar HindujaB commented on May 24, 2024

I agree with the comment from @MaryamZi. We can't depend on the getConstituentTypes() to return a type-reference type for the first element. It can vary depending on the record descriptor. At runtime, we use a recursive method called getImpliedType() to extract the underlying record type.
There is a relevant compiler FE API, which we can use.


(Need to move this API to a proper class.)
And, we may need to check the anonymous flags to identify the record name.

from ballerina-lang.

Dilhasha avatar Dilhasha commented on May 24, 2024

Agree with the comments. We'll check on a proper implementation for the initial requirement.

from ballerina-lang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.