Skip to content

checker: improve pos for if expr #22845

Merged
spytheman merged 3 commits intovlang:masterfrom
Delta456:if_expr
Nov 13, 2024
Merged

checker: improve pos for if expr #22845
spytheman merged 3 commits intovlang:masterfrom
Delta456:if_expr

Conversation

@Delta456
Copy link
Copy Markdown
Member

Improves position for If-Expr conditions

Before

code.v:5:14: error: `if` expression requires an expression as the last statement of every branch
    3 |     mut start := 0
    4 | 
    5 |     start += if val < 20 { start += 1  } else { start }
      |              ~~~~~~~~~~~
    6 |     dump(start)
    7 | }

After

vlib/v/checker/tests/if_expr_last_branch_stmt_err.vv:5:30: error: `if` expression requires an expression as the last statement of every branch
   3 |     mut start := 0
   4 | 
   5 |     start = if val < 20 { start += 1 } else { start }
     |                                 ~~
   6 |     dump(start)
   7 | }

Copy link
Copy Markdown
Contributor

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit f4d3c7e into vlang:master Nov 13, 2024
@Delta456 Delta456 deleted the if_expr branch December 26, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants