ballerina-platform / ballerina-lang

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

[Bug]: Generating a method call with an invalid method name when calling with a readonly object value #43323

Closed heshanpadmasiri closed 1 month ago

heshanpadmasiri commented 2 months ago

Description

When trying to run nBallerina with the latest master (34a9f70) we get the fallowing error message.

error: No such method: $gen$(wso2&0047nballerina&0046comm&0046diagnostic&00580&0058$anonType$File$_0 & readonly)&0046filename
    at wso2.nballerina.comm.diagnostic.0:format(diagnostic.bal:123)
       wso2.nballerina.comm.diagnostic.0.ConsolePrinter:print(printer.bal:18)
       wso2.nballerina.0:main(main.bal:77)

This seems to be a regression introduced around the tag v2201.9.2 though this was not observed with the release version 9.2.

When diagnosing I observed in diagnostic.class file this,

old (working)

Screenshot 2024-08-26 at 18 09 13

broken (new)

Screenshot 2024-08-26 at 18 11 01

Steps to Reproduce

  1. Clone nBallerina repository
  2. Run bal build
  3. Go to target\bin and run java -jar nballerina.jar ../../testSuite/01-boolean/not1-e.bal (this should work with any test file with -e suffix)

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

heshanpadmasiri commented 2 months ago

This seems to be an regression introduced with e977d9f3a07835716ef081f62500e0dfec54a866

HindujaB commented 2 months ago

Reproducible with this sample code

public type File readonly & object {
    public function filename() returns string;
};

public function format(File file) {
    string line = file.filename();
}

public readonly class VirtualFile {
    *File;
    public function filename() returns string => "Hello";
}

public function main() {
    File d = new VirtualFile();
    format(d);
}
HindujaB commented 1 month ago

The fix will be released with the 9.4 and 10.1 patch versions as well.

https://github.com/ballerina-platform/ballerina-release/issues/2750 https://github.com/ballerina-platform/ballerina-release/issues/2751

github-actions[bot] commented 1 month 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.