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

Revisit flags set to differentiate between the different kinds of fields of a record #37624

Open
SasinduDilshara opened this issue Sep 5, 2022 · 1 comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement

Comments

@SasinduDilshara
Copy link
Contributor

SasinduDilshara commented Sep 5, 2022

Description

Currently defaultable fields in record types does not contain Field and DEFAULTABLE_PARAM field flags.
Please refer to this comment also. #37491 (comment).

type CustomRecord record {
    readonly int id = 1;  // id field does not contain `Field` and `DEFAULTABLE_PARAM` field flags. Need to add `DEFAULTABLE_PARAM` and `Field` flags
    string name;
};

function testDefaultValueFieldAsKeyField2() {
    table<CustomRecord> key (id) tb = table [
        {id: 2, name: "Amy"}
    ];
}

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Labels

CompilerFE

Related issue(s) (optional)

#33298

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@github-actions github-actions bot added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Sep 5, 2022
@SasinduDilshara SasinduDilshara changed the title DEFAULTABLE_PARAM Flag is not defined for defaultable fields in Ballerina record types DEFAULTABLE_PARAM and Field Flags are not defined for defaultable fields in Ballerina record types Sep 5, 2022
@MaryamZi
Copy link
Member

The isn't a bug. DEFAULTABLE_PARAM is specifically for defaultable parameters.

The improvement we can do is revisiting how we model the three different kinds of individual fields of a record:

  • required field without a default value
  • required field with a default value
  • optional field

Right now, the flags are set as follows.

  • required field without a default value - REQUIRED
  • optional field - OPTIONAL

A required field with a default value is then identified by the absence of both flags (REQUIRED and OPTIONAL). But this isn't exactly clear with spec terms.

This issue is to see how we can improve the flags (probably have three different flags to reflect the three kinds).

@MaryamZi MaryamZi changed the title DEFAULTABLE_PARAM and Field Flags are not defined for defaultable fields in Ballerina record types Revisit flags set to differentiate between the different kinds of fields of a record Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement
Projects
None yet
Development

No branches or pull requests

2 participants