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

[Improvement]: Hide Other type from Compiler diagnostics #40358

Open
hasithaa opened this issue May 8, 2023 · 3 comments
Open

[Improvement]: Hide Other type from Compiler diagnostics #40358

hasithaa opened this issue May 8, 2023 · 3 comments
Labels
Area/Compiler Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement

Comments

@hasithaa
Copy link
Contributor

hasithaa commented May 8, 2023

Description

This is not a helpful error message for the end user. Mostly these are generated as a side effect due to an incomplete type checker rule.

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

@hasithaa hasithaa added Type/Improvement Area/Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler labels May 8, 2023
@hasithaa
Copy link
Contributor Author

hasithaa commented May 8, 2023

One option is to suppress the diagnostics if one of the parameters is a type of other. But we have to make sure at least one other error diagnostic is present, before suppressing such diagnostics.

@MaryamZi @gimantha @pcnfernando thoughts ?

@pcnfernando
Copy link
Member

One option is to suppress the diagnostics if one of the parameters is a type of other. But we have to make sure at least one other error diagnostic is present, before suppressing such diagnostics.

@MaryamZi @gimantha @pcnfernando thoughts ?

What if; instead of suppressing, rephrase the error message? Maybe something like the one below. It's useful to know that the actual value is incompatible or type resolving failed

eg:

invalid remote method call: expected a client object, but found 'other' -> invalid remote method call: expected a client object, but the actual type is incompatible.
incompatible types: expected 'error', found 'other' -> incompatible types: expected 'error', but the actual type is incompatible.

@MaryamZi
Copy link
Member

MaryamZi commented May 8, 2023

+1 to skip logging diagnostics with SymbolTable#semanticError.

What if; instead of suppressing, rephrase the error message? Maybe something like the one below. It's useful to know that the actual value is incompatible or type resolving failed

eg:

invalid remote method call: expected a client object, but found 'other' -> invalid remote method call: expected a client object, but the actual type is incompatible.
incompatible types: expected 'error', found 'other' -> incompatible types: expected 'error', but the actual type is incompatible.

But usually, we don't know anything about the type when it is semantic error, right? We can't say anything additional until the original issue is fixed. So I don't think we should say incompatible.

For example,

import ballerina/http;

public function main() returns error? {
    http:Client cl = check new ("http://localhost:8080");
    json payload = check c->get("/");
}

Here, the error is because of a typo, and this results in the following errors at the moment.

$ bal run temp.bal 
Compiling source
        temp.bal
ERROR [temp.bal:(5:26,5:37)] invalid remote method call: expected a client object, but found 'other'
ERROR [temp.bal:(5:26,5:27)] undefined symbol 'c'

IMO, it is enough to have just "undefined symbol 'c'", because fixing that will resolve both of the (current) errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Compiler Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants