Skip to content

fix[lang]: fix precedence in floordiv hint#4203

Merged
charles-cooper merged 10 commits intovyperlang:masterfrom
cyberthirst:fix/braces-in-hints
Aug 6, 2024
Merged

fix[lang]: fix precedence in floordiv hint#4203
charles-cooper merged 10 commits intovyperlang:masterfrom
cyberthirst:fix/braces-in-hints

Conversation

@cyberthirst
Copy link
Copy Markdown
Collaborator

@cyberthirst cyberthirst commented Aug 2, 2024

What I did

Commit Message

fix parenthesisation of child exprs in the floordiv hint. previously,
an expression like
```vyper
(x + y) / z
```

could result in a hint suggesting something with incorrect precedence,
like
```vyper
x + y // z
```

this commit conservatively adds parentheses to the hint whenever the
expr in question has child binops.

@cyberthirst
Copy link
Copy Markdown
Collaborator Author

we don't need to handle braces for AugAssign, right?

elif isinstance(node, vy_ast.AugAssign):

@cyberthirst cyberthirst added this to the v0.4.1 milestone Aug 5, 2024
@charles-cooper charles-cooper changed the title fix[lang]: fix braces for division hint fix[lang]: fix parentheses for floordiv hint Aug 6, 2024
Copy link
Copy Markdown
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

thank you!

@charles-cooper charles-cooper changed the title fix[lang]: fix parentheses for floordiv hint fix[lang]: fix parentheses in floordiv hint Aug 6, 2024
@charles-cooper charles-cooper changed the title fix[lang]: fix parentheses in floordiv hint fix[lang]: fix precedence in floordiv hint Aug 6, 2024
@charles-cooper charles-cooper enabled auto-merge (squash) August 6, 2024 03:53
@charles-cooper charles-cooper merged commit b91730b into vyperlang:master Aug 6, 2024
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.

Compiler gives incorrect arithmetic hint for decimal division

3 participants