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

@pcnfernando pcnfernando moved this from BackLog to Planned for the Sprint in Sprint 64 - Compiler Frontend, Integration and Parser Sep 7, 2022
@gimantha gimantha moved this from Planned for the Sprint to In Progress in Sprint 64 - Compiler Frontend, Integration and Parser Sep 14, 2022
@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

@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