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]: CCE in query with string as expected type #40038

Closed
SasinduDilshara opened this issue Mar 30, 2023 · 1 comment · Fixed by #40041
Closed

[Bug]: CCE in query with string as expected type #40038

SasinduDilshara opened this issue Mar 30, 2023 · 1 comment · Fixed by #40041

Comments

@SasinduDilshara
Copy link
Contributor

Description

function queryWithString2() returns error? {
    stream<Book, error?> bookStream = [{ author: "Author 1", title: "Title 1" }, 
                                        {author: "Author 2", title: "Title 2" }].toStream();

    string strValue = check from Book _ in bookStream
        select <string:Char> "a";
}
public function main() {

    error? testQueryWithXmlResult2 = trap queryWithString2();
    if (testQueryWithXmlResult2 is error) {
        io:println(testQueryWithXmlResult2);
    }
}

Gives

Compiling source
        a.bal
WARNING [a.bal:(12:5,13:34)] unused variable 'strValue'

Running executable

[2023-03-30 10:45:00,661] SEVERE {b7a.log.crash} - class java.lang.String cannot be cast to class io.ballerina.runtime.api.values.BValue (java.lang.String is in module java.base of loader 'bootstrap'; io.ballerina.runtime.api.values.BValue is in unnamed module of loader 'app') 
java.lang.ClassCastException: class java.lang.String cannot be cast to class io.ballerina.runtime.api.values.BValue (java.lang.String is in module java.base of loader 'bootstrap'; io.ballerina.runtime.api.values.BValue is in unnamed module of loader 'app')
        at io.ballerina.runtime.internal.TypeChecker.getType(TypeChecker.java:367)
        at io.ballerina.runtime.internal.ErrorUtils.createNumericConversionError(ErrorUtils.java:148)
        at io.ballerina.runtime.internal.TypeConverter.stringToChar(TypeConverter.java:930)
        at io.ballerina.runtime.internal.TypeConverter.anyToChar(TypeConverter.java:992)
        at a.queryWithString2(a.bal:12)
        at a.main(a.bal:17)
        at $_init.$moduleExecute(.)
        at $_init.$lambda$$moduleExecute$(.)
        at io.ballerina.runtime.internal.scheduling.SchedulerItem.execute(SchedulerItem.java:54)
        at io.ballerina.runtime.internal.scheduling.Scheduler.run(Scheduler.java:306)
        at io.ballerina.runtime.internal.scheduling.Scheduler.runSafely(Scheduler.java:273)
        at java.base/java.lang.Thread.run(Thread.java:829)

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

@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
Projects
Archived in project
2 participants