mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[FunC] Require parenthesis in tricky bitwise precedence cases
Example: "flags & 0xFF != 0" is equivalent to "flags & 1", most likely it's unexpected. Example: "a << 2 + 1" (equal to "a << 3", probably unexpected). The only way to suppress this error for the programmer is to use parenthesis.
This commit is contained in:
parent
5867d52926
commit
79721d230e
10 changed files with 189 additions and 10 deletions
|
@ -946,7 +946,7 @@ struct Expr {
|
|||
};
|
||||
ExprCls cls;
|
||||
int val{0};
|
||||
enum { _IsType = 1, _IsRvalue = 2, _IsLvalue = 4, _IsImpure = 32 };
|
||||
enum { _IsType = 1, _IsRvalue = 2, _IsLvalue = 4, _IsImpure = 32, _IsInsideParenthesis = 64 };
|
||||
int flags{0};
|
||||
SrcLocation here;
|
||||
td::RefInt256 intval;
|
||||
|
@ -988,6 +988,9 @@ struct Expr {
|
|||
bool is_type() const {
|
||||
return flags & _IsType;
|
||||
}
|
||||
bool is_inside_parenthesis() const {
|
||||
return flags & _IsInsideParenthesis;
|
||||
}
|
||||
bool is_type_apply() const {
|
||||
return cls == _TypeApply;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue