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

Incorrect diagnostic property in query expression #37450

Closed
TharushiJay opened this issue Aug 19, 2022 · 4 comments · Fixed by #37547 or #41117
Closed

Incorrect diagnostic property in query expression #37450

TharushiJay opened this issue Aug 19, 2022 · 4 comments · Fixed by #37547 or #41117
Assignees
Labels
Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@TharushiJay
Copy link
Contributor

Description:
Consider the diagnostic variable assignment is required at cursor position.

Screenshot 2022-08-19 at 09 29 30

In the diagnostic properties which is used to derive the expected type, we get the bType incorrectly as xml<string> where it should be string[].

Screenshot 2022-08-19 at 09 28 14

For a different case like x1.toBalString(), we get the type correctly as string in the diagnostic properties.

Steps to reproduce:

public function main() {
    xml x1 = xml `<book>The Lost World</book>`;

    from xml element in x1 select element.toBalString();
}

Affected Versions:
2201.2.0 (Swan Lake Update 2)

@pcnfernando
Copy link
Member

As per the spec https://ballerina.io/spec/lang/master/#section_6.35,

If there is no contextually expected type, then the basic type of the value constructed is the basic type of expression following in; it is a compile-time error if the static type of this expression is not a subtype of one of the basic types that a query expression can construct.

The basic type the query being resolved to seem to be correct because x1 is a XML. But the constraint comes from the select clause, which is string in this case. Hence the type resolved would be xml<string>. But since we cannot constraint XML with string, we should get an error saying

@github-actions
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.

@SasinduDilshara
Copy link
Contributor

This issue was reopened due to #40497

@SasinduDilshara SasinduDilshara moved this from Done to Planned for Sprint in Ballerina Team Main Board May 24, 2023
@pcnfernando pcnfernando removed the Points/3 Equivalent to three days effort label May 25, 2023
@pcnfernando pcnfernando added this to the 2201.7.0 milestone May 25, 2023
@pcnfernando pcnfernando moved this from Planned for Sprint to In Progress in Ballerina Team Main Board May 30, 2023
@pcnfernando pcnfernando moved this from In Progress to On Hold in Ballerina Team Main Board May 30, 2023
@gimantha gimantha removed this from the 2201.7.0 milestone Jun 15, 2023
@pcnfernando pcnfernando moved this from On Hold to In Progress in Ballerina Team Main Board Jul 18, 2023
@pcnfernando pcnfernando moved this from In Progress to Planned for Sprint in Ballerina Team Main Board Jul 20, 2023
@pcnfernando pcnfernando moved this from Planned for Sprint to In Progress in Ballerina Team Main Board Jul 20, 2023
@pcnfernando pcnfernando moved this from In Progress to PR Sent in Ballerina Team Main Board Jul 31, 2023
@github-project-automation github-project-automation bot moved this from PR Sent to Done in Ballerina Team Main Board Aug 18, 2023
@github-actions
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
Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
Archived in project
5 participants