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]: Variety of incorrect diagnostic messages generated for duplicate keys in mapping constructors #40348

Open
pubudu91 opened this issue May 3, 2023 · 0 comments
Labels
needTriage The issue has to be inspected and labeled manually Type/Bug userCategory/Compilation

Comments

@pubudu91
Copy link
Contributor

pubudu91 commented May 3, 2023

Description

Consider the following:

map<[decimal, int]> m = {
    "1": [1.2, 3],
    "1": [5.6, 7]
};

We get the following error message for the above:

invalid usage of map literal: duplicate key '1'

But when the mapping constructor is used in other expression contexts, it keeps giving different different diagnostic messages of the same variant of the above. e.g.,

bar({
    "1": [1.2, 3],
    "1": [5.6, 7]
});

error: invalid usage of null literal: duplicate key '1'

if {
    "1": [1.2, 3],
    "1": [5.6, 7]
} is map<[decimal, int]> {
    io:println("map");
}

error: invalid usage of boolean literal: duplicate key '1'

var v = {
    "1": [1.2, 3],
    "1": [5.6, 7]
}.toString();

error: invalid usage of string literal: duplicate key '1'

Steps to Reproduce

No response

Affected Version(s)

2201.5.0
2201.2.3

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

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needTriage The issue has to be inspected and labeled manually Type/Bug userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

2 participants