ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

Fix issue in change return type CA

Open KavinduZoysa opened this issue 11 months ago • 4 comments

Purpose

Fixes #42292

KavinduZoysa avatar Mar 14 '24 04:03 KavinduZoysa

IMO what we are currently doing is not correct.

Consider a case like this,

public type Error1 distinct error;
public type Error2 distinct error;

function bar1() returns int|Error1 {
    int i = check foo1();
    return foo2();
}

function foo1() returns int|Error1 => 1;
function foo2() returns int|Error2 => 1;

When we apply the above code action the return type will be change to int|Error2|error. In this case it should be int|Error1|error or int|Error1|Error2. For better DX with handing the exact error type we should give int|Error1|Error2.

I think in this code what we should do following things,

  1. Update existing return type by adding public distinct error types coming from other modules. If the error types are in the same module we need to add those error types as well.
  2. Where there are non-public error types we should add generic error type.

We had a similar discussion on this #42127.

LakshanWeerasinghe avatar Mar 18 '24 06:03 LakshanWeerasinghe

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

github-actions[bot] avatar Apr 02 '24 19:04 github-actions[bot]

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

github-actions[bot] avatar Apr 18 '24 19:04 github-actions[bot]

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

github-actions[bot] avatar May 06 '24 19:05 github-actions[bot]

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

github-actions[bot] avatar May 22 '24 19:05 github-actions[bot]

Closed PR due to inactivity for more than 18 days.

github-actions[bot] avatar May 26 '24 19:05 github-actions[bot]

This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the stale label is removed or commented.

github-actions[bot] avatar Sep 03 '24 19:09 github-actions[bot]

@LakshanWeerasinghe @KavinduZoysa Shall we resolve the conflicts and get this reviewed?

gimantha avatar Sep 18 '24 06:09 gimantha

Closing this PR since we have to revisit the approach again.

KavinduZoysa avatar Sep 20 '24 08:09 KavinduZoysa