Skip to content

[Compiler] Support optional chaining in compiler #3984

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

Merged
merged 5 commits into from
May 29, 2025

Conversation

SupunS
Copy link
Member

@SupunS SupunS commented May 28, 2025

Work towards #3976

Description

Performs a nil check on the target/parent before accessing a field or a method. If the target/parent is not nil, then unwraps the value and proceed to access the field or invoke a method on it. Otherwise, if the target/parent is nil, simply load a nil value onto the stack.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@SupunS SupunS self-assigned this May 28, 2025
@SupunS SupunS added the Feature label May 28, 2025
Copy link

github-actions bot commented May 28, 2025

Cadence Benchstat comparison

This branch with compared with the base branch onflow:feature/compiler commit 98d3f17
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -benchmem -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Collapsed results for better readability

@SupunS SupunS force-pushed the supun/optional-chaining branch from b4dbcc1 to fb71a34 Compare May 28, 2025 23:19
@SupunS SupunS marked this pull request as ready for review May 28, 2025 23:25
@SupunS SupunS requested a review from turbolent as a code owner May 28, 2025 23:25
@SupunS SupunS requested a review from RZhang05 May 28, 2025 23:26
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 👏

@SupunS SupunS enabled auto-merge May 29, 2025 17:16
@SupunS SupunS merged commit cd6f627 into feature/compiler May 29, 2025
8 of 9 checks passed
@SupunS SupunS deleted the supun/optional-chaining branch May 29, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants