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

[Improve-optional-field-access-desugar] Desugar field access expression to if statement expression #43770

Conversation

rdulmina
Copy link
Contributor

Purpose

$title

Fixes #43769

Approach

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;
 

Check List

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • Added necessary tests
    • Unit Tests
    • Spec Conformance Tests
    • Integration Tests
    • Ballerina By Example Tests
  • Increased Test Coverage
  • Added necessary documentation
    • API documentation
    • Module documentation in Module.md files
    • Ballerina By Examples

@rdulmina rdulmina added the Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. label Jan 27, 2025
@rdulmina rdulmina changed the base branch from master to 2201.10.x January 27, 2025 11:17
@rdulmina rdulmina force-pushed the Improve-optional-field-access-desugar branch from d24b7c3 to 11a53ba Compare January 27, 2025 11:23
@rdulmina rdulmina changed the base branch from 2201.10.x to Improve-optional-field-access-desugar January 27, 2025 11:24
@rdulmina rdulmina force-pushed the Improve-optional-field-access-desugar branch from 11a53ba to e56c689 Compare January 27, 2025 11:32
@rdulmina rdulmina merged commit e3246f5 into ballerina-platform:Improve-optional-field-access-desugar Jan 27, 2025
2 checks passed
@rdulmina rdulmina changed the title Desugar field access expression to if statement expression [Improve-optional-field-access-desugar] Desugar field access expression to if statement expression Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Improve field access expression desugar
1 participant