ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.57k stars 738 forks source link

Runtime CCE for field-access-expr #36988

Open SandaruJayawardana opened 2 years ago

SandaruJayawardana commented 2 years ago

Description: $title.

public function main() returns error? {
    map<map<map<json>>> x2 = {a: {a: {a: 2}}, b: {a: {c: "string"}}};
    json|error y2 = (x2.c).b;
}

Error:

Running executable

[2022-07-14 11:38:52,370] SEVERE {b7a.log.crash} - class io.ballerina.runtime.internal.values.ErrorValue cannot be cast to class io.ballerina.runtime.internal.values.MapValue (io.ballerina.runtime.internal.values.ErrorValue and io.ballerina.runtime.internal.values.MapValue are in unnamed module of loader 'app') 
java.lang.ClassCastException: class io.ballerina.runtime.internal.values.ErrorValue cannot be cast to class io.ballerina.runtime.internal.values.MapValue (io.ballerina.runtime.internal.values.ErrorValue and io.ballerina.runtime.internal.values.MapValue are in unnamed module of loader 'app')
        at test.main(test.bal:3)
        at $_init.$lambda$main$(.)
        at io.ballerina.runtime.internal.scheduling.SchedulerItem.execute(Scheduler.java:594)
        at io.ballerina.runtime.internal.scheduling.Scheduler.run(Scheduler.java:321)
        at io.ballerina.runtime.internal.scheduling.Scheduler.runSafely(Scheduler.java:288)
        at java.base/java.lang.Thread.run(Thread.java:834)

Affected Versions: Current master

gabilang commented 2 years ago

It looks like this is happening due to some issues while desugaring map<map<map<json>>> (or higher orders) for field access. So, need to be looked at from front-end. Hence, removing the jBallerina tag.

SandaruJayawardana commented 2 years ago

Similar behavior in optional-field-access-expr also.

MaryamZi commented 1 year ago

Works as expected on Swan Lake Update 3 RCs. Keeping the issue open to add tests.