Skip to content
New issue

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

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

Already on GitHub? # to your account

[Improvement]: Improve field access expression desugar #43769

Closed
rdulmina opened this issue Jan 27, 2025 · 1 comment · Fixed by #43770 or #43782
Closed

[Improvement]: Improve field access expression desugar #43769

rdulmina opened this issue Jan 27, 2025 · 1 comment · Fixed by #43770 or #43782
Assignees
Labels
Fix/Crash All issues caused by NPE, CCE, etc Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement
Milestone

Comments

@rdulmina
Copy link
Contributor

Description

Currently, the field access expression desugared in to match statement which cases lot of instructions when there is a large chain access of the field access expression. This could lead to unwanted method to large errors at runtime.

Need to find a better way of desugaring eg: Try to desugar into if statement.

Related internal issue: https://github.com/wso2-enterprise/internal-support-ballerina/issues/862

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

@rdulmina rdulmina added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement labels Jan 27, 2025
@rdulmina rdulmina self-assigned this Jan 27, 2025
@rdulmina
Copy link
Contributor Author

Desugared field access expression to the following structure

// Before :
type A {
  B b;
}
type B {
 int c;
}
int? res = a?.b?.c

// After desugar :
any|error temp_result;
temp_result = a;
if temp_result !is error? {
    temp_result = (<A> temp_result).b;
    if temp_result !is error? {
        temp_result = (<B> temp_result).c;
    }
}
int? res = <int> temp_result;
 

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Fix/Crash All issues caused by NPE, CCE, etc Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement
Projects
Status: Done
1 participant