Skip to content

Commit

Permalink
Update lint.md (#634)
Browse files Browse the repository at this point in the history
Add documentation for IntegerParsing and ComparisonPrecedence lints
  • Loading branch information
zeux committed Aug 11, 2022
1 parent e15b072 commit 2c40b76
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/_pages/lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,26 @@ Luau uses comments that start from `!` to control certain aspects of analysis, f
-- Unknown comment directive 'nostrict'; did you mean 'nonstrict'?"
```
```
## IntegerParsing (27)
Luau parses hexadecimal and binary literals as 64-bit integers before converting them to Luau numbers. As a result, numbers that exceed 2^64 are silently truncated to 2^64, which can result in unexpected program behavior. This warning flags literals that are truncated:
```
-- Hexadecimal number literal exceeded available precision and has been truncated to 2^64
local x = 0x1111111111111111111111111111111111111
```
## ComparisonPrecedence (28)
Because of operator precedence rules, not X == Y parses as (not X) == Y; however, often the intent was to invert the result of the comparison. This warning flags erroneous conditions like that, as well as flagging cases where two comparisons happen in a row without any parentheses:
```
-- not X == Y is equivalent to (not X) == Y; consider using X ~= Y, or wrap one of the expressions in parentheses to silence
if not x == 5 then
end

-- X <= Y <= Z is equivalent to (X <= Y) <= Z; wrap one of the expressions in parentheses to silence
if 1 <= x <= 3 then
end
```

0 comments on commit 2c40b76

Please sign in to comment.