ballerina-platform / nballerina

Ballerina compiler that generates native executables.
https://ballerina.io/
Apache License 2.0
138 stars 46 forks source link

constBitCast fails with named struct when struct body has not been set #705

Closed jclark closed 2 years ago

jclark commented 2 years ago

I need to call constBitCast on a named struct when I haven't yet set the body of the struct.

I get a crash here:

[fail] testCompileEU#'future/record2-uv.bal':

            {ballerina/lang.map}KeyNotFound {"message":"cannot find key '%Type0'"}

                at ballerina.lang.map.0:get(map.bal:65)
                wso2.nballerina.print:getStructName(llvm.bal:251)
                wso2.nballerina.print.llvm.0:typeToString(llvm.bal:1444)
                wso2.nballerina.print.llvm.0:typeToString(llvm.bal:1438)
                wso2.nballerina.print.llvm.0:bitCastArgs(llvm.bal:1673)
                wso2.nballerina.print:constBitCast(llvm.bal:190)
jclark commented 2 years ago

The named struct code needs some work. Not ok to do linear searches in namedStructTypes all the time.

jclark commented 2 years ago

I put in a workaround, but I don't really understand what the code is doing. Shouldn't it always be converting a named struct to a string by using the name?