ballerina-platform / ballerina-lang

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

[Bug]: `NoSuchMethodError` exception when running with tuple destructure #41174

Open dulajdilshan opened 1 year ago

dulajdilshan commented 1 year ago

Description

$title

[2023-12-08 13:30:41,785] SEVERE {b7a.log.crash} - 'java.lang.Object $value$$anonType$_2.$gen$$0046$0060init$0062(io.ballerina.runtime.internal.scheduling.Strand, io.ballerina.runtime.internal.values.MapValue)'
java.lang.NoSuchMethodError: 'java.lang.Object $value$$anonType$_2.$gen$$0046$0060init$0062(io.ballerina.runtime.internal.scheduling.Strand, io.ballerina.runtime.internal.values.MapValue)'
    at $value$$anonType$_2.$init($value$$anonType$_2)
    at creators.$_records.createRecordValue0(Unknown Source)
    at creators.$_records.createRecordValue(Unknown Source)
    at $_init.createRecordValue(.)
    at io.ballerina.runtime.internal.ValueUtils.createRecordValue(ValueUtils.java:62)
    at io.ballerina.runtime.api.creators.ValueCreator.createRecordValue(ValueCreator.java:835)
    at io.ballerina.runtime.internal.types.BRecordType.getZeroValue(BRecordType.java:123)
    at io.ballerina.runtime.internal.values.TupleValueImpl.<init>(TupleValueImpl.java:196)
    at io.ballerina.runtime.internal.values.TupleValueImpl.<init>(TupleValueImpl.java:201)
    at io.ballerina.runtime.internal.values.TypedescValueImpl.instantiate(TypedescValueImpl.java:103)
    at bal1.main(bal1.bal:8)
    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:833)

Steps to Reproduce

Try running the following codes with bal run

scene 1:

public function main() {
    int a;
    int b;
    int c;

    var f = function () returns record {|int a; int b;|} => {a: 1, b: 2};

    [{a, b}, {c}] = [f()];
}

scene 2 (Currently this shows incorrect errors, and it will be fixed in https://github.com/ballerina-platform/ballerina-lang/pull/40283):

public function main() {
    int a;
    int b;
    [{a, b}] = [{a: 1, b: 2}];
}

Affected Version(s)

2201.7.0 at least

OS, DB, other environment details and versions

Ubuntu 22.04

Related area

-> Runtime

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

chiranSachintha commented 11 months ago

The following scenario resolved by the closure PR https://github.com/ballerina-platform/ballerina-lang/pull/40579

public function main() {
    int a;
    int b;
    int c;

    var f = function () returns record {|int a; int b;|} => {a: 1, b: 2};

    [{a, b}, {c}] = [f()];
}
github-actions[bot] commented 10 months ago

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.

MaryamZi commented 2 months ago

May all be fixed now.