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]: Unable to distinguish enum symbol from union-type symbol in Semantic API #38179

Closed
MohamedSabthar opened this issue Oct 12, 2022 · 7 comments
Assignees
Labels
Area/SemanticAPI Semantic API Related Issues #Compiler Planning/SwanLake2023 Temporary Label for issue to be fixed immediately. Points/2 Equivalent to two days effort Reason/Invalid Issue is invalid. Team/CompilerFETools Semantic API, Formatter, Shell Type/Bug userCategory/Compilation

Comments

@MohamedSabthar
Copy link
Member

Description

Consider following code

public enum Baz {
    # This is open
    OPEN,
    # This is close
    CLOSE
}

public type State Baz;

TypeReferenceTypeSymbol typeReferenceTypeSymbol = <State>; // I have set the State as typereferenceTypeSymbol
calling typeReferenceTypeSymbol.typeDescriptor() returns UnionTypeSymbol but it should return EnumSymbol

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

@MohamedSabthar MohamedSabthar added Type/Bug Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Oct 12, 2022
@dulajdilshan dulajdilshan added Team/CompilerFETools Semantic API, Formatter, Shell Area/SemanticAPI Semantic API Related Issues #Compiler and removed Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. labels Oct 12, 2022
@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Oct 12, 2022
@LakshanWeerasinghe LakshanWeerasinghe removed the needTriage The issue has to be inspected and labeled manually label Oct 20, 2022
@LakshanWeerasinghe LakshanWeerasinghe added the Points/2 Equivalent to two days effort label Oct 20, 2022
@mohanvive mohanvive added the Planning/SwanLake2023 Temporary Label for issue to be fixed immediately. label Feb 20, 2023
@dulajdilshan
Copy link
Contributor

We can get the enum-type by typeReferenceTypeSymbol.definition()

@lnash94
Copy link
Member

lnash94 commented Jul 25, 2023

enum Result {
    NOTAVAILABLE,
    AVAILABLE
}

type RAction Result;

When we are going to take typeDescriptor() from RAction it returns BallerinaUnionTypeSymbol instead of TypeReference. Is this the expected type?

Reference issue: ballerina-platform/ballerina-library#5123

@dulajdilshan
Copy link
Contributor

This is a kind of expected behavior (according to the design decisions). Therefore, we are fixing @lnash94's original issue (which is "unable to distinguish enum and union-type) by introducing new APIs within UnionTypeSymbol

enum Result {
    NOTAVAILABLE,
    AVAILABLE
}

type RAction Result;

When we are going to take typeDescriptor() from RAction it returns BallerinaUnionTypeSymbol instead of TypeReference. Is this the expected type?

Reference issue: ballerina-platform/ballerina-standard-library#5123

@dulajdilshan
Copy link
Contributor

Changing the issue title to "[Bug]: Unable to distinguish enum symbol from union-type symbol in Semantic API" due to this

This is a kind of expected behavior (according to the design decisions). Therefore, we are fixing @lnash94's original issue (which is "unable to distinguish enum and union-type) by introducing new APIs within UnionTypeSymbol

@dulajdilshan dulajdilshan changed the title [Bug]: Calling typeDescriptor() on TypeReferenceTypeSymbol doesn't return expected symbol type [Bug]: Unable to distinguish enum symbol from union-type symbol in Semantic API Aug 8, 2023
@dulajdilshan dulajdilshan moved this from In Progress to PR Sent in Ballerina Team Main Board Aug 8, 2023
@dulajdilshan
Copy link
Contributor

We had a discussion sometime back with @MaryamZi and @lnash94, and decided not to send any updates for this since we shouldn't expose any attributes through UnionTypeSymbol to check whether it is an enum or not (complying with the spec), The correct behaviour would be - the Semantic API user should get the visible-symbols and retrieve the enum symbol

@MaryamZi MaryamZi moved this from PR Sent to On Hold in Ballerina Team Main Board Sep 5, 2023
@dulajdilshan
Copy link
Contributor

Closing this due to the last comment

Copy link

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/SemanticAPI Semantic API Related Issues #Compiler Planning/SwanLake2023 Temporary Label for issue to be fixed immediately. Points/2 Equivalent to two days effort Reason/Invalid Issue is invalid. Team/CompilerFETools Semantic API, Formatter, Shell Type/Bug userCategory/Compilation
Projects
None yet
7 participants