-
Notifications
You must be signed in to change notification settings - Fork 59
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
feat: support binary operations for function return type #184
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the middle of it, but I'm wondering why the addition of all that code when we can already rely on the parser to warn when there's no parenthesis in an expression of binary operations. I know we discussed that before but it's still not clear to me (again) why we don't just parse an expression there and then convert it later to something we can use
src/parser/types.rs
Outdated
token | ||
} else { | ||
tokens.bump(ctx).unwrap() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe buff_token.or_else(|| tokens.bump(ctx)).unwrap()
?
I think the short answer for now is that the signatures parsing is for constructing types, while the expression parsing is not about the type. |
mm I'm not sure I follow, can't you just parse the whole expression at this point with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good tho!
Let me try to reason through the differences. The pub struct Ty {
pub kind: TyKind,
pub span: Span,
} While the pub struct Expr {
pub node_id: usize,
pub kind: ExprKind,
pub span: Span,
} Because What your question inspired me to think of is: what if we can use So yeah, looks like the use of |
yeah, it really simplifies the things a lot! |
nice! (I would even suggest changing the |
It is quite common to see scenarios like:
So this PR is to support the binary operations over symbolic size for function return type.