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

autocast Option type to real type inside if foo != none scope #18790

Closed
1 of 2 tasks
ArtemkaKun opened this issue Jul 5, 2023 · 0 comments · Fixed by #20275
Closed
1 of 2 tasks

autocast Option type to real type inside if foo != none scope #18790

ArtemkaKun opened this issue Jul 5, 2023 · 0 comments · Fixed by #20275
Assignees
Labels
Feature Request This issue is made to request a feature. Option Type Bugs/feature requests, that are related to `?Type`.

Comments

@ArtemkaKun
Copy link
Contributor

Describe the feature

Currently we have

if app.selected_point_id != none {
  point_to_move_id := app.selected_point_id or { return }

  app.polygon_points[point_to_move_id] = trnsfrm2d.Position{
    x: event.mouse_x
    y: event.mouse_y
  }
}

Option should be autocasted from ?int to int in if app.selected_point_id != none block, since this block will be executed only when Option != none.

if app.selected_point_id != none {
  app.polygon_points[app.selected_point_id] = trnsfrm2d.Position{
    x: event.mouse_x
    y: event.mouse_y
  }
}

Use Case

This will reduce amount of strange code need to be written when working with Option types.

Proposed Solution

@fe

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4

Environment details (OS name and version, etc.)

Not related

@ArtemkaKun ArtemkaKun added Feature Request This issue is made to request a feature. Option Type Bugs/feature requests, that are related to `?Type`. labels Jul 5, 2023
@felipensp felipensp self-assigned this Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature. Option Type Bugs/feature requests, that are related to `?Type`.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants