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

Full definition of a union type given in error messages related to union typed variables #11056

Closed
pubudu91 opened this issue Oct 29, 2018 · 4 comments
Labels
Area/Compiler Area/DiagnosticAPI Diagnostics API related Issues #Compiler Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler Area/SemanticAPI Semantic API Related Issues #Compiler Priority/High SwanLakeDump All issues planned for Swan Lake GA release Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@pubudu91
Copy link
Contributor

Consider the following program:

type ValueType int|float|string|boolean|byte;
type DataType ValueType|table|json|xml|map|();

public function main() {
    map<DataType> m;
    map<int> m2 = m;
}

Running the above program results in the following compilation error:

error: .::test2.bal:6:19: incompatible types: expected 'map<int>', found 'map<int|float|string|boolean|byte|table|json|xml|map?>'

Instead of saying map<int|float|string|boolean|byte|table|json|xml|map?>, it should be saying map<DataType>.

@anupama-pathirage anupama-pathirage added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Apr 30, 2019
@hasithaa hasithaa added this to New Issues in Ballerina Compiler Team Tasks via automation Aug 1, 2019
@hasithaa
Copy link
Contributor

hasithaa commented Aug 1, 2019

The same requirement came for LS. This requires persists original typenode information into AST/symbols.

@gimantha gimantha added this to Needs triage in Ballerina Compiler Bug triage via automation Oct 18, 2019
@gimantha gimantha moved this from Needs triage to Patch Compatible 1.0.x in Ballerina Compiler Bug triage Oct 18, 2019
@gimantha gimantha added this to the Ballerina 1.0.x milestone Oct 18, 2019
@gimantha gimantha added this to BackLog in Sprint 1 - Compiler Front-End via automation Oct 31, 2019
@gimantha gimantha moved this from BackLog to Temporary Column in Sprint 1 - Compiler Front-End Oct 31, 2019
@gimantha gimantha moved this from Patch Compatible to [Reviewed] Patch compatible in Ballerina Compiler Bug triage Nov 1, 2019
@hasithaa hasithaa removed this from the Ballerina 1.0.x milestone Apr 24, 2020
@hasithaa hasithaa moved this from [Reviewed] Patch compatible to Diagnostics Rewrite in Ballerina Compiler Bug triage Apr 24, 2020
@hasithaa hasithaa added Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler Area/DiagnosticAPI Diagnostics API related Issues #Compiler Area/SemanticAPI Semantic API Related Issues #Compiler SwanLakeDump All issues planned for Swan Lake GA release labels Aug 24, 2020
@rasika
Copy link
Contributor

rasika commented Feb 17, 2021

We need to prioritize this issue as the langserver generated codes are not intuitive. Related issue #28684

@MaryamZi
Copy link
Member

With #29362, the compilation error has been updated.

type ValueType int|float|string|boolean|byte;
type DataType ValueType|table<record {}>|json|xml|map<any>|();

public function main() {
    map<DataType> m;
    map<int> m2 = m;
}

now results in

ERROR [foo.bal:(6:19,6:20)] incompatible types: expected 'map<int>', found 'map<DataType>'

The original member types of a union type can be accessed via the BType using org.wso2.ballerinalang.compiler.semantics.model.types.BUnionType#getOriginalMemberTypes.

@pubudu91
Copy link
Contributor Author

pubudu91 commented May 3, 2021

@MaryamZi Can this be closed now or are there other cases to consider?

@MaryamZi MaryamZi closed this as completed Jun 8, 2021
Ballerina Compiler Bug triage automation moved this from Diagnostics Rewrite to [Done] Closed Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Compiler Area/DiagnosticAPI Diagnostics API related Issues #Compiler Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler Area/SemanticAPI Semantic API Related Issues #Compiler Priority/High SwanLakeDump All issues planned for Swan Lake GA release Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
No open projects
Development

No branches or pull requests

6 participants