Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Missing Distinct Qualifier in ObjectTypeSymbol #40619

Closed
DimuthuMadushan opened this issue Jun 7, 2023 · 9 comments · Fixed by #40901
Closed

[Bug]: Missing Distinct Qualifier in ObjectTypeSymbol #40619

DimuthuMadushan opened this issue Jun 7, 2023 · 9 comments · Fixed by #40901
Assignees
Labels
Area/Compiler Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation

Comments

@DimuthuMadushan
Copy link
Contributor

Description

The distinct qualifier of Interceptor type in the following code is missing in the ObjectTypeSymbol. Tried to access the qualifiers using objectTypeSymbol.qualifiers() API. Since the qualifier is missing, it cannot be validated at the compiler plugin.

public type Interceptor distinct service object {
    isolated remote function execute(Context context, Field 'field) returns anydata|error;
};

readonly service class ServiceInterceptor {
    *graphql:Interceptor;

    isolated remote function execute(graphql:Context context, graphql:Field 'field) returns anydata|error {
        anydata|error result = context.resolve('field);
        return result;
    }
}

service graphql:Service on new graphql:Listener(4000) {
    resource function get foo() returns graphql:Interceptor {
        return new ServiceInterceptor();
    }
}

This issue is similar to the #37560 which was fixed earlier. But it seems the fix is a partial fix. It doesn't capture the distinct qualifier in types like Interceptors. This doesn't work in u4, u5, u6. But this works with u5 latest timestamp.

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Jun 7, 2023
@MaryamZi MaryamZi added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Jun 7, 2023
@MaryamZi MaryamZi added Type/Bug and removed Type/Improvement needTriage The issue has to be inspected and labeled manually labels Jun 8, 2023
@LakshanWeerasinghe LakshanWeerasinghe self-assigned this Jun 9, 2023
@rdulmina rdulmina changed the title [Improvement]: Missing Distinct Qualifier in ObjectTypeSymbol [Bug]: Missing Distinct Qualifier in ObjectTypeSymbol Jun 12, 2023
@MaryamZi
Copy link
Member

@LakshanWeerasinghe mentioned that the origin is different (SOURCE vs COMPILED_SOURCE) when the flag is available vs not available. So, it's basically that the flag is not available via the BIR.

This already seems to be the case on 2201.5.0. With the new version of GraphQL (v1.8.0) compatible with 2201.5.0, once it is pulled, there is an extra error for https://github.com/ballerina-platform/module-ballerina-graphql/blob/master/compiler-plugin-tests/src/test/resources/ballerina_sources/validator_tests/27_invalid_return_types/service.bal on the second compilation (when it is via the BIR). So this is not something new on 2201.5.x. The reason for this failing on 2201.5.x seems to be due to the source being used for the test instead of the BIR, which seems to be different from what happened previously. That'll have to be looked into separately.

@MaryamZi
Copy link
Member

The reason for this failing on 2201.5.x seems to be due to the source being used for the test instead of the BIR, which seems to be different from what happened previously. That'll have to be looked into separately.

This could also be due to the new v1.8.0 release. We need to check if v1.8.0 is pulled for the compiler plugin test.

@LakshanWeerasinghe
Copy link
Contributor

When fixing this issues following this have been identified.

  1. When the object network qualifier is a client it will identified as a service qualifier.
  2. isolated qualifier is not read from the BIR.
  3. When we use the flags value read from the inputstream in the BIR to set the tSymbol flag it will give a compiler crash.

I will be looking in to the above cases as well.

@MaryamZi
Copy link
Member

2. isolated qualifier is not read from the BIR.

Can you please share an example for this? Just wondering for what scenarios this is the case because isolated-ness is widely used with client objects in libraries and we have tests in org.ballerinalang.test.bala.isolation.IsolationAnalysisBalaTest too.

@LakshanWeerasinghe
Copy link
Contributor

public type Interceptor distinct isolated client object {
    isolated remote function execute() returns anydata|error;
};

I used the above code snippet to try that out. When I unmask the
Screenshot 2023-06-27 at 14 16 02
flags I got the below results.

@MaryamZi
Copy link
Member

The following worked for me via the BIR too.

import maryam/foo;

isolated client readonly class InterceptorImpl {
    *foo:Interceptor;

    isolated remote function execute() returns anydata|error => 1;
}

final foo:Interceptor fi = new InterceptorImpl();

public isolated function main() returns error? {
    _ = check fi->execute(); // if `foo:Interceptor` is not `isolated` this should result in an error
}

It could be being set elsewhere.

@LakshanWeerasinghe
Copy link
Contributor

public type Interceptor distinct isolated client object {
    isolated remote function execute() returns anydata|error;
};

I used the above code snippet to try that out. When I unmask the Screenshot 2023-06-27 at 14 16 02 flags I got the below results.

This behavior has occurred due to caching issue when running the tests. Hence ignore this comment.

@LakshanWeerasinghe
Copy link
Contributor

When fixing this issues following this have been identified.

  1. When the object network qualifier is a client it will identified as a service qualifier.
  2. isolated qualifier is not read from the BIR.
  3. When we use the flags value read from the inputstream in the BIR to set the tSymbol flag it will give a compiler crash.

I will be looking in to the above cases as well.

1 & 2. This happened due to a cache issue.
All the type level flags are propagated properly. When we create the BSymbol we propagate the flags one by one. Because of this reason we have missed the qualifiers like distinct, isolated at the BSymbol.

@github-actions
Copy link

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.

@pcnfernando pcnfernando added the Reason/EngineeringMistake The issue occurred due to a mistake made in the past. label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Compiler Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation
Projects
Archived in project
5 participants